2001-06-23 11:09:40 +00:00
< ? php
2004-08-21 06:42:38 +00:00
/**
* @ file
* Configuration system that lets administrators modify the workings of the site .
*/
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Component\FileSecurity\FileSecurity ;
2018-11-19 11:59:53 +00:00
use Drupal\Component\Gettext\PoItem ;
2015-10-01 23:25:03 +00:00
use Drupal\Component\Render\PlainTextOutput ;
2014-11-14 10:43:20 +00:00
use Drupal\Component\Utility\UrlHelper ;
2015-01-21 15:21:06 +00:00
use Drupal\Core\Asset\AttachedAssetsInterface ;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\Block\BlockPluginInterface ;
2013-03-22 09:36:55 +00:00
use Drupal\Core\Cache\Cache ;
2015-10-06 11:02:22 +00:00
use Drupal\Core\Database\Query\AlterableInterface ;
2023-02-22 15:28:49 +00:00
use Drupal\Core\Datetime\TimeZoneFormHelper ;
2020-02-24 13:25:58 +00:00
use Drupal\Core\Entity\ContentEntityTypeInterface ;
Issue #2921810 by claudiu.cristea, nod_, seanB, yogeshmpawar, dww, Wilfred Waltman, joelpittet, askibinski, ankithashetty, ravi.shankar, jonathanshaw, alexpott, kostyashupenko, webchick, danflanagan8, catch, droplet, larowlan, mpdonadio, jhedstrom, AaronMcHale, dawehner, Wim Leers, ckrina, worldlinemine: Allow TimestampFormatter to show as a fully cacheable time difference with JS
2023-03-03 16:35:58 +00:00
use Drupal\Core\Entity\Display\EntityViewDisplayInterface ;
Issue #3223209 by kim.pepper, dww, yogeshmpawar, daffie, larowlan, Berdir, andypost, phenaproxima, brianV, alexpott, AjitS, ravi.shankar, catch, quietone, trobey, Dave Reid, JacobSingh, imclean, tim.plunkett, Kars-T, amateescu, JeremyFrench, aaron: deprecate file_save_data, file_copy and file_move and replace with a service
2021-10-25 01:01:32 +00:00
use Drupal\Core\Extension\Extension ;
Issue #2921810 by claudiu.cristea, nod_, seanB, yogeshmpawar, dww, Wilfred Waltman, joelpittet, askibinski, ankithashetty, ravi.shankar, jonathanshaw, alexpott, kostyashupenko, webchick, danflanagan8, catch, droplet, larowlan, mpdonadio, jhedstrom, AaronMcHale, dawehner, Wim Leers, ckrina, worldlinemine: Allow TimestampFormatter to show as a fully cacheable time difference with JS
2023-03-03 16:35:58 +00:00
use Drupal\Core\Field\Plugin\Field\FieldFormatter\TimestampFormatter ;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\File\Exception\FileException ;
Issue #3223209 by kim.pepper, dww, yogeshmpawar, daffie, larowlan, Berdir, andypost, phenaproxima, brianV, alexpott, AjitS, ravi.shankar, catch, quietone, trobey, Dave Reid, JacobSingh, imclean, tim.plunkett, Kars-T, amateescu, JeremyFrench, aaron: deprecate file_save_data, file_copy and file_move and replace with a service
2021-10-25 01:01:32 +00:00
use Drupal\Core\File\Exception\InvalidStreamWrapperException ;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\File\FileSystemInterface ;
2014-07-31 00:50:42 +00:00
use Drupal\Core\Form\FormStateInterface ;
2014-12-04 12:31:10 +00:00
use Drupal\Core\KeyValueStore\KeyValueDatabaseExpirableFactory ;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\Language\LanguageInterface ;
Issue #3041885 by tedbow, beautifulmind, dww, ayushmishra206, phenaproxima, webchick, xjm, AaronMcHale, larowlan, benjifisher, heddn, catch, jhodgdon, longwave, mglaman, alexpott, mxr576, effulgentsia: Display relevant Security Advisories data for Drupal
2021-05-12 06:40:17 +00:00
use Drupal\Core\Link ;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\Menu\MenuTreeParameters ;
2015-07-03 19:52:58 +00:00
use Drupal\Core\PageCache\RequestPolicyInterface ;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\Queue\QueueGarbageCollectionInterface ;
2014-06-30 03:33:08 +00:00
use Drupal\Core\Routing\RouteMatchInterface ;
2016-01-05 05:56:08 +00:00
use Drupal\Core\Routing\StackedRouteMatchInterface ;
SA-CORE-2022-012 by cmlara, GuyPaddock, larowlan, mondrake, effulgentsia, xjm, longwave, Dave Reid, lauriii, David Strauss, benjifisher, alexpott, mcdruid, Fabianx
(cherry picked from commit 1f82337d1789424dcb1901eb68b820a7e141d8c5)
2022-07-20 15:11:30 +00:00
use Drupal\Core\Site\Settings ;
SA-CORE-2023-005 by benjifisher, Heine, cmlara, mlhess, larowlan, David_Rothstein, xjm, Wim Leers, DamienMcKenna, effulgentsia, pwolanin, mcdruid, poker10, jenlampton, longwave, kim.pepper, alexpott, drumm
2023-04-19 16:18:37 +00:00
use Drupal\Core\StreamWrapper\LocalStream ;
SA-CORE-2022-012 by cmlara, GuyPaddock, larowlan, mondrake, effulgentsia, xjm, longwave, Dave Reid, lauriii, David Strauss, benjifisher, alexpott, mcdruid, Fabianx
(cherry picked from commit 1f82337d1789424dcb1901eb68b820a7e141d8c5)
2022-07-20 15:11:30 +00:00
use Drupal\Core\StreamWrapper\StreamWrapperManager ;
2014-08-07 20:43:27 +00:00
use Drupal\Core\Url ;
2020-12-21 06:26:56 +00:00
use GuzzleHttp\Exception\TransferException ;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Symfony\Component\HttpFoundation\RedirectResponse ;
2012-04-28 05:57:24 +00:00
2014-04-24 13:06:35 +00:00
/**
2020-11-30 18:10:49 +00:00
* Disabled option on forms and settings .
2009-06-05 05:28:28 +00:00
*/
2011-11-29 09:56:53 +00:00
const DRUPAL_DISABLED = 0 ;
2009-06-05 05:28:28 +00:00
/**
2020-11-30 18:10:49 +00:00
* Optional option on forms and settings .
2009-06-05 05:28:28 +00:00
*/
2011-11-29 09:56:53 +00:00
const DRUPAL_OPTIONAL = 1 ;
2009-06-05 05:28:28 +00:00
/**
2020-11-30 18:10:49 +00:00
* Required option on forms and settings .
2009-06-05 05:28:28 +00:00
*/
2011-11-29 09:56:53 +00:00
const DRUPAL_REQUIRED = 2 ;
2009-06-05 05:28:28 +00:00
2009-07-18 02:36:01 +00:00
/**
2010-03-27 05:52:50 +00:00
* Return only visible regions .
2010-03-26 17:14:46 +00:00
*
* @ see system_region_list ()
2009-07-18 02:36:01 +00:00
*/
2011-11-29 09:56:53 +00:00
const REGIONS_VISIBLE = 'visible' ;
2009-07-18 02:36:01 +00:00
/**
2010-03-27 05:52:50 +00:00
* Return all regions .
2010-03-26 17:14:46 +00:00
*
* @ see system_region_list ()
2009-07-18 02:36:01 +00:00
*/
2011-11-29 09:56:53 +00:00
const REGIONS_ALL = 'all' ;
2009-07-18 02:36:01 +00:00
2004-06-18 15:04:37 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_help () .
2004-06-18 15:04:37 +00:00
*/
2014-06-30 03:33:08 +00:00
function system_help ( $route_name , RouteMatchInterface $route_match ) {
2014-05-07 02:04:53 +00:00
switch ( $route_name ) {
case 'help.page.system' :
2009-12-01 13:43:11 +00:00
$output = '' ;
$output .= '<h3>' . t ( 'About' ) . '</h3>' ;
2017-03-04 01:20:24 +00:00
$output .= '<p>' . t ( 'The System module is integral to the site: it provides user interfaces for many core systems and settings, as well as the basic administrative menu structure. For more information, see the <a href=":system">online documentation for the System module</a>.' , [ ':system' => 'https://www.drupal.org/documentation/modules/system' ]) . '</p>' ;
2009-12-01 13:43:11 +00:00
$output .= '<h3>' . t ( 'Uses' ) . '</h3>' ;
$output .= '<dl>' ;
$output .= '<dt>' . t ( 'Managing modules' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'Users with appropriate permission can install and uninstall modules from the <a href=":modules">Extend page</a>. Depending on which distribution or installation profile you choose when you install your site, several modules are installed and others are provided but not installed. Each module provides a discrete set of features; modules may be installed or uninstalled depending on the needs of the site. Many additional modules contributed by members of the Drupal community are available for download from the <a href=":drupal-modules">Drupal.org module page</a>. Note that uninstalling a module is a destructive action: when you uninstall a module, you will permanently lose all data connected to the module.' , [ ':modules' => Url :: fromRoute ( 'system.modules_list' ) -> toString (), ':drupal-modules' => 'https://www.drupal.org/project/modules' ]) . '</dd>' ;
2009-12-01 13:43:11 +00:00
$output .= '<dt>' . t ( 'Managing themes' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'Users with appropriate permission can install and uninstall themes on the <a href=":themes">Appearance page</a>. Themes determine the design and presentation of your site. Depending on which distribution or installation profile you choose when you install your site, a default theme is installed, and possibly a different theme for administration pages. Other themes are provided but not installed, and additional contributed themes are available at the <a href=":drupal-themes">Drupal.org theme page</a>.' , [ ':themes' => Url :: fromRoute ( 'system.themes_page' ) -> toString (), ':drupal-themes' => 'https://www.drupal.org/project/themes' ]) . '</dd>' ;
2014-09-27 07:27:32 +00:00
$output .= '<dt>' . t ( 'Disabling drag-and-drop functionality' ) . '</dt>' ;
2015-02-18 17:20:35 +00:00
$output .= '<dd>' . t ( 'The default drag-and-drop user interface for ordering tables in the administrative interface presents a challenge for some users, including users of screen readers and other assistive technology. The drag-and-drop interface can be disabled in a table by clicking a link labeled "Show row weights" above the table. The replacement interface allows users to order the table by choosing numerical weights instead of dragging table rows.' ) . '</dd>' ;
$output .= '<dt>' . t ( 'Configuring basic site settings' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'The System module provides pages for managing basic site configuration, including <a href=":date-time-settings">Date and time formats</a> and <a href=":site-info">Basic site settings</a> (site name, email address to send mail from, home page, and error pages). Additional configuration pages are listed on the main <a href=":config">Configuration page</a>.' , [ ':date-time-settings' => Url :: fromRoute ( 'entity.date_format.collection' ) -> toString (), ':site-info' => Url :: fromRoute ( 'system.site_information_settings' ) -> toString (), ':config' => Url :: fromRoute ( 'system.admin_config' ) -> toString ()]) . '</dd>' ;
2015-10-06 18:37:02 +00:00
$output .= '<dt>' . t ( 'Checking site status' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'The <a href=":status">Status report</a> provides an overview of the configuration, status, and health of your site. Review this report to make sure there are not any problems to address, and to find information about the software your site and web server are using.' , [ ':status' => Url :: fromRoute ( 'system.status' ) -> toString ()]) . '</dd>' ;
2015-02-18 17:20:35 +00:00
$output .= '<dt>' . t ( 'Using maintenance mode' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'When you are performing site maintenance, you can prevent non-administrative users (including anonymous visitors) from viewing your site by putting it in <a href=":maintenance-mode">Maintenance mode</a>. This will prevent unauthorized users from making changes to the site while you are performing maintenance, or from seeing a broken site while updates are in progress.' , [ ':maintenance-mode' => Url :: fromRoute ( 'system.site_maintenance_mode' ) -> toString ()]) . '</dd>' ;
2015-06-03 21:00:40 +00:00
$output .= '<dt>' . t ( 'Configuring for performance' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'On the <a href=":performance-page">Performance page</a>, the site can be configured to aggregate CSS and JavaScript files, making the total request size smaller. Note that, for small- to medium-sized websites, the <a href=":page-cache">Internal Page Cache module</a> should be installed so that pages are efficiently cached and reused for anonymous users. Finally, for websites of all sizes, the <a href=":dynamic-page-cache">Dynamic Page Cache module</a> should also be installed so that the non-personalized parts of pages are efficiently cached (for all users).' , [ ':performance-page' => Url :: fromRoute ( 'system.performance_settings' ) -> toString (), ':page-cache' => ( \Drupal :: moduleHandler () -> moduleExists ( 'page_cache' )) ? Url :: fromRoute ( 'help.page' , [ 'name' => 'page_cache' ]) -> toString () : '#' , ':dynamic-page-cache' => ( \Drupal :: moduleHandler () -> moduleExists ( 'dynamic_page_cache' )) ? Url :: fromRoute ( 'help.page' , [ 'name' => 'dynamic_page_cache' ]) -> toString () : '#' ]) . '</dd>' ;
2015-02-18 17:20:35 +00:00
$output .= '<dt>' . t ( 'Configuring cron' ) . '</dt>' ;
2023-01-13 09:42:59 +00:00
$output .= '<dd>' . t ( 'In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis; these operations are known as <em>cron</em> tasks. On the <a href=":cron">Cron page</a>, you can configure cron to run periodically as part of server responses by installing the <em>Automated Cron</em> module, or you can turn this off and trigger cron from an outside process on your web server. You can verify the status of cron tasks by visiting the <a href=":status">Status report page</a>. For more information, see the <a href=":handbook">online documentation for configuring cron jobs</a>.' , [ ':status' => Url :: fromRoute ( 'system.status' ) -> toString (), ':handbook' => 'https://www.drupal.org/docs/administering-a-drupal-site/cron-automated-tasks/cron-automated-tasks-overview' , ':cron' => Url :: fromRoute ( 'system.cron_settings' ) -> toString ()]) . '</dd>' ;
2015-02-18 17:20:35 +00:00
$output .= '<dt>' . t ( 'Configuring the file system' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'Your site has several file directories, which are used to store and process uploaded and generated files. The <em>public</em> file directory, which is configured in your settings.php file, is the default place for storing uploaded files. Links to files in this directory contain the direct file URL, so when the files are requested, the web server will send them directly without invoking your site code. This means that the files can be downloaded by anyone with the file URL, so requests are not access-controlled but they are efficient. The <em>private</em> file directory, also configured in your settings.php file and ideally located outside the site web root, is access controlled. Links to files in this directory are not direct, so requests to these files are mediated by your site code. This means that your site can check file access permission for each file before deciding to fulfill the request, so the requests are more secure, but less efficient. You should only use the private storage for files that need access control, not for files like your site logo and background images used on every page. The <em>temporary</em> file directory is used internally by your site code for various operations, and is configured on the <a href=":file-system">File system settings</a> page. You can also see the configured public and private file directories on this page, and choose whether public or private should be the default for uploaded files.' , [ ':file-system' => Url :: fromRoute ( 'system.file_system_settings' ) -> toString ()]) . '</dd>' ;
2015-02-18 17:20:35 +00:00
$output .= '<dt>' . t ( 'Configuring the image toolkit' ) . '</dt>' ;
2019-04-16 05:38:27 +00:00
$output .= '<dd>' . t ( 'On the <a href=":toolkit">Image toolkit page</a>, you can select and configure the PHP toolkit used to manipulate images. Depending on which distribution or installation profile you choose when you install your site, the GD2 toolkit and possibly others are included; other toolkits may be provided by contributed modules.' , [ ':toolkit' => Url :: fromRoute ( 'system.image_toolkit_settings' ) -> toString ()]) . '</dd>' ;
Issue #3041885 by tedbow, beautifulmind, dww, ayushmishra206, phenaproxima, webchick, xjm, AaronMcHale, larowlan, benjifisher, heddn, catch, jhodgdon, longwave, mglaman, alexpott, mxr576, effulgentsia: Display relevant Security Advisories data for Drupal
2021-05-12 06:40:17 +00:00
if ( \Drupal :: currentUser () -> hasPermission ( 'administer site configuration' )) {
$output .= '<dt id="security-advisories">' . t ( 'Critical security advisories' ) . '</dt>' ;
$output .= '<dd>' . t ( 'The System module displays highly critical and time-sensitive security announcements to site administrators. Some security announcements will be displayed until a critical security update is installed. Announcements that are not associated with a specific release will appear for a fixed period of time. <a href=":handbook">More information on critical security advisories</a>.' , [ ':handbook' => 'https://www.drupal.org/docs/updating-drupal/responding-to-critical-security-update-advisories' ]) . '</dd>' ;
$output .= '<dd>' . t ( 'Only the most highly critical security announcements will be shown. <a href=":advisories-list">View all security announcements</a>.' , [ ':advisories-list' => 'https://www.drupal.org/security' ]) . '</dd>' ;
}
2014-12-08 11:11:21 +00:00
$output .= '</dl>' ;
2005-11-01 10:17:34 +00:00
return $output ;
2014-05-07 02:04:53 +00:00
case 'system.admin_index' :
2008-04-14 17:48:46 +00:00
return '<p>' . t ( 'This page shows you all available administration tasks for each module.' ) . '</p>' ;
2014-05-07 02:04:53 +00:00
case 'system.themes_page' :
2017-03-04 01:20:24 +00:00
$output = '<p>' . t ( 'Set and configure the default theme for your website. Alternative <a href=":themes">themes</a> are available.' , [ ':themes' => 'https://www.drupal.org/project/themes' ]) . '</p>' ;
Issue #2513556 by dcmul, mohit_aghera, cilefen, subhojit777, hussainweb, Bojhan, eliza411, ivanstegic, LewisNyman, lunk_rat, nickrosencrans, stpaultim, Mark LaCroix, webchick: Add a link to the Block Layout page on the Appearance page
2015-09-07 17:07:19 +00:00
if ( \Drupal :: moduleHandler () -> moduleExists ( 'block' )) {
2019-04-16 05:38:27 +00:00
$output .= '<p>' . t ( 'You can place blocks for each theme on the <a href=":blocks">block layout</a> page.' , [ ':blocks' => Url :: fromRoute ( 'block.admin_display' ) -> toString ()]) . '</p>' ;
Issue #2513556 by dcmul, mohit_aghera, cilefen, subhojit777, hussainweb, Bojhan, eliza411, ivanstegic, LewisNyman, lunk_rat, nickrosencrans, stpaultim, Mark LaCroix, webchick: Add a link to the Block Layout page on the Appearance page
2015-09-07 17:07:19 +00:00
}
2007-11-24 20:35:37 +00:00
return $output ;
2014-05-07 02:04:53 +00:00
case 'system.theme_settings_theme' :
2015-01-13 10:17:01 +00:00
$theme_list = \Drupal :: service ( 'theme_handler' ) -> listInfo ();
2014-06-30 03:33:08 +00:00
$theme = $theme_list [ $route_match -> getParameter ( 'theme' )];
2017-03-04 01:20:24 +00:00
return '<p>' . t ( 'These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.' , [ '%name' => $theme -> info [ 'name' ]]) . '</p>' ;
2014-05-07 02:04:53 +00:00
case 'system.theme_settings' :
2016-07-22 17:47:49 +00:00
return '<p>' . t ( 'Control default display settings for your site, across all themes. Use theme-specific settings to override these defaults.' ) . '</p>' ;
2014-05-07 02:04:53 +00:00
case 'system.modules_list' :
Issue #2577407 by vulcanr, jhodgdon, Sagar Ramgade, snehi, brahmjeet789, Manjit.Singh, Tony-Mac, ressa, xjm, cilefen, sajosh, ifrik, Charles Belov, Bojhan, David_Rothstein, Gábor Hojtsy, tkoleary, longwave, NickDickinsonWilde, nishantkumar155, shell_cm, greta_drupal, YesCT: Action of uploading module/theme files should consistently be called "Add", not "Install"
2020-12-06 19:02:44 +00:00
$output = '<p>' . t ( 'Add <a href=":modules">contributed modules</a> to extend your site\'s functionality.' , [ ':modules' => 'https://www.drupal.org/project/modules' ]) . '</p>' ;
2015-08-29 06:56:40 +00:00
if ( ! \Drupal :: moduleHandler () -> moduleExists ( 'update' )) {
2023-03-29 01:36:22 +00:00
$output .= '<p>' . t ( 'Regularly review available updates and update as required to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time a module is updated. Install the <a href=":update-manager">Update Manager module</a> to update and add modules and themes.' , [ ':update-php' => Url :: fromRoute ( 'system.db_update' ) -> toString (), ':update-manager' => Url :: fromRoute ( 'system.modules_list' , [], [ 'fragment' => 'module-update' ]) -> toString ()]) . '</p>' ;
2009-10-25 19:52:47 +00:00
}
2007-07-03 19:11:14 +00:00
return $output ;
2014-05-07 02:04:53 +00:00
case 'system.modules_uninstall' :
2013-09-19 16:22:53 +00:00
return '<p>' . t ( 'The uninstall process removes all data related to a module.' ) . '</p>' ;
2014-05-07 02:04:53 +00:00
2014-08-04 16:55:19 +00:00
case 'entity.block.edit_form' :
Issue #2030571 by calebtr, daffie, filijonka, YesCT, Thomas Brekelmans, alexpott, Mile23, tadityar, Sharique, tim.plunkett, boztek: Expand Block with methods
2015-01-12 17:47:19 +00:00
if (( $block = $route_match -> getParameter ( 'block' )) && $block -> getPluginId () == 'system_powered_by_block' ) {
2008-04-14 17:48:46 +00:00
return '<p>' . t ( 'The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.' ) . '</p>' ;
2007-10-17 15:24:56 +00:00
}
2007-11-05 16:00:55 +00:00
break ;
2014-05-07 02:04:53 +00:00
case 'block.admin_add' :
2014-06-30 03:33:08 +00:00
if ( $route_match -> getParameter ( 'plugin_id' ) == 'system_powered_by_block' ) {
2014-05-07 02:04:53 +00:00
return '<p>' . t ( 'The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.' ) . '</p>' ;
}
break ;
case 'system.site_maintenance_mode' :
2013-12-12 11:03:09 +00:00
if ( \Drupal :: currentUser () -> id () == 1 ) {
2011-09-24 20:23:02 +00:00
return '<p>' . t ( 'Use maintenance mode when making major updates, particularly if the updates could disrupt visitors or the update process. Examples include upgrading, importing or exporting content, modifying a theme, modifying content types, and making backups.' ) . '</p>' ;
2009-07-04 14:29:34 +00:00
}
2010-11-26 10:55:55 +00:00
break ;
2014-05-07 02:04:53 +00:00
case 'system.status' :
2020-08-03 09:10:21 +00:00
return '<p>' . t ( " Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on Drupal.org's support forums and project issue queues. Before filing a support request, ensure that your web server meets the <a href= \" :system-requirements \" >system requirements.</a> " , [ ':system-requirements' => 'https://www.drupal.org/docs/system-requirements' ]) . '</p>' ;
2003-08-21 18:13:28 +00:00
}
2002-02-07 19:59:37 +00:00
}
2007-12-16 21:01:45 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_theme () .
2007-12-16 21:01:45 +00:00
*/
2007-04-06 13:27:23 +00:00
function system_theme () {
2017-03-04 01:20:24 +00:00
return array_merge ( drupal_common_theme (), [
2014-03-03 16:38:08 +00:00
// Normally theme suggestion templates are only picked up when they are in
Issue #1869476 by rteijeiro, LewisNyman, lauriii, Wim Leers, mdrummond, swentel, hosef, cbiggins, larowlan, sun, EclipseGc, Gábor Hojtsy: Convert global menus (primary links, secondary links) into blocks.
2014-09-29 01:25:41 +00:00
// themes. We explicitly define theme suggestions here so that the block
// templates in core/modules/system/templates are picked up.
2017-03-04 01:20:24 +00:00
'block__system_branding_block' => [
Issue #1869476 by rteijeiro, LewisNyman, lauriii, Wim Leers, mdrummond, swentel, hosef, cbiggins, larowlan, sun, EclipseGc, Gábor Hojtsy: Convert global menus (primary links, secondary links) into blocks.
2014-09-29 01:25:41 +00:00
'render element' => 'elements' ,
2014-03-03 16:38:08 +00:00
'base hook' => 'block' ,
2017-03-04 01:20:24 +00:00
],
'block__system_messages_block' => [
2015-03-13 09:54:28 +00:00
'base hook' => 'block' ,
2017-03-04 01:20:24 +00:00
],
'block__system_menu_block' => [
Issue #1869476 by rteijeiro, LewisNyman, lauriii, Wim Leers, mdrummond, swentel, hosef, cbiggins, larowlan, sun, EclipseGc, Gábor Hojtsy: Convert global menus (primary links, secondary links) into blocks.
2014-09-29 01:25:41 +00:00
'render element' => 'elements' ,
'base hook' => 'block' ,
2017-03-04 01:20:24 +00:00
],
'system_themes_page' => [
'variables' => [
'theme_groups' => [],
'theme_group_titles' => [],
],
2009-05-21 23:07:16 +00:00
'file' => 'system.admin.inc' ,
2017-03-04 01:20:24 +00:00
],
'system_config_form' => [
2009-10-23 22:24:19 +00:00
'render element' => 'form' ,
2017-03-04 01:20:24 +00:00
],
'confirm_form' => [
2009-10-23 22:24:19 +00:00
'render element' => 'form' ,
2017-03-04 01:20:24 +00:00
],
'system_modules_details' => [
2009-10-23 22:24:19 +00:00
'render element' => 'form' ,
2009-05-21 23:07:16 +00:00
'file' => 'system.admin.inc' ,
2017-03-04 01:20:24 +00:00
],
'system_modules_uninstall' => [
2009-10-23 22:24:19 +00:00
'render element' => 'form' ,
2009-05-21 23:07:16 +00:00
'file' => 'system.admin.inc' ,
2017-03-04 01:20:24 +00:00
],
'status_report_page' => [
'variables' => [
'counters' => [],
'general_info' => [],
Issue #665790 by chrisrockwell, Sumit kumar, lauriii, joelpittet, sun, vulcanr, vaplas, yoroy, leahtard, tompagabor, aspilicious, ckrina, Gábor Hojtsy, David_Rothstein, Manuel Garcia, rootwork, nod_, kostyashupenko, pguillard, Bojhan, droplet, typhonius, wturrell, mgifford, webkenny, cosmicdreams, tkoleary, YesCT, marcvangend, markabur, LewisNyman, mrfelton, oriol_e9g, prabhu9484, catch, hedrickbt, tsvenson, longwave, dww, kika, borisson_, rdellis87, realityloop, klonos: Redesign the status report page
2017-02-07 20:44:09 +00:00
'requirements' => NULL ,
2017-03-04 01:20:24 +00:00
],
],
'status_report' => [
'variables' => [
Issue #665790 by chrisrockwell, Sumit kumar, lauriii, joelpittet, sun, vulcanr, vaplas, yoroy, leahtard, tompagabor, aspilicious, ckrina, Gábor Hojtsy, David_Rothstein, Manuel Garcia, rootwork, nod_, kostyashupenko, pguillard, Bojhan, droplet, typhonius, wturrell, mgifford, webkenny, cosmicdreams, tkoleary, YesCT, marcvangend, markabur, LewisNyman, mrfelton, oriol_e9g, prabhu9484, catch, hedrickbt, tsvenson, longwave, dww, kika, borisson_, rdellis87, realityloop, klonos: Redesign the status report page
2017-02-07 20:44:09 +00:00
'grouped_requirements' => NULL ,
'requirements' => NULL ,
2017-03-04 01:20:24 +00:00
],
],
'status_report_grouped' => [
'variables' => [
Issue #665790 by chrisrockwell, Sumit kumar, lauriii, joelpittet, sun, vulcanr, vaplas, yoroy, leahtard, tompagabor, aspilicious, ckrina, Gábor Hojtsy, David_Rothstein, Manuel Garcia, rootwork, nod_, kostyashupenko, pguillard, Bojhan, droplet, typhonius, wturrell, mgifford, webkenny, cosmicdreams, tkoleary, YesCT, marcvangend, markabur, LewisNyman, mrfelton, oriol_e9g, prabhu9484, catch, hedrickbt, tsvenson, longwave, dww, kika, borisson_, rdellis87, realityloop, klonos: Redesign the status report page
2017-02-07 20:44:09 +00:00
'grouped_requirements' => NULL ,
'requirements' => NULL ,
2017-03-04 01:20:24 +00:00
],
],
'status_report_counter' => [
'variables' => [ 'amount' => NULL , 'text' => NULL , 'severity' => NULL ],
],
'status_report_general_info' => [
'variables' => [
'drupal' => [],
'cron' => [],
'database_system' => [],
'database_system_version' => [],
'php' => [],
'php_memory_limit' => [],
'webserver' => [],
],
],
'admin_page' => [
'variables' => [ 'blocks' => NULL ],
2009-05-21 23:07:16 +00:00
'file' => 'system.admin.inc' ,
2017-03-04 01:20:24 +00:00
],
'admin_block' => [
2017-09-05 09:08:13 +00:00
'variables' => [ 'block' => NULL , 'attributes' => []],
2009-05-21 23:07:16 +00:00
'file' => 'system.admin.inc' ,
2017-03-04 01:20:24 +00:00
],
'admin_block_content' => [
'variables' => [ 'content' => NULL ],
2009-05-21 23:07:16 +00:00
'file' => 'system.admin.inc' ,
2017-03-04 01:20:24 +00:00
],
'system_admin_index' => [
'variables' => [ 'menu_items' => NULL ],
2009-05-21 23:07:16 +00:00
'file' => 'system.admin.inc' ,
2017-03-04 01:20:24 +00:00
],
'entity_add_list' => [
'variables' => [
'bundles' => [],
2016-03-14 09:21:48 +00:00
'add_bundle_message' => NULL ,
2017-03-04 01:20:24 +00:00
],
2016-03-14 09:21:48 +00:00
'template' => 'entity-add-list' ,
2017-03-04 01:20:24 +00:00
],
2017-10-24 22:46:32 +00:00
'off_canvas_page_wrapper' => [
'variables' => [ 'children' => NULL ],
],
Issue #3041885 by tedbow, beautifulmind, dww, ayushmishra206, phenaproxima, webchick, xjm, AaronMcHale, larowlan, benjifisher, heddn, catch, jhodgdon, longwave, mglaman, alexpott, mxr576, effulgentsia: Display relevant Security Advisories data for Drupal
2021-05-12 06:40:17 +00:00
'system_security_advisories_fetch_error_message' => [
'file' => 'system.theme.inc' ,
'variables' => [ 'error_message' => []],
],
Issue #2941208 by AdamPS, dpi, sja112, aleevas, andypost, anmolgoyal74, Spokje, jofitz, Rinku Jacob 13, jonathanshaw, plach, larowlan, alexpott, catch, lauriii: Title formatting broken due to flawed EntityViewController->buildTitle
2022-02-21 09:09:24 +00:00
'entity_page_title' => [
'variables' => [
'attributes' => [],
'title' => NULL ,
'entity' => NULL ,
'view_mode' => NULL ,
],
],
2017-03-04 01:20:24 +00:00
]);
2007-04-06 13:27:23 +00:00
}
2007-12-16 21:01:45 +00:00
2009-10-16 03:01:55 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_hook_info () .
2009-10-16 03:01:55 +00:00
*/
function system_hook_info () {
2017-03-04 01:20:24 +00:00
$hooks [ 'token_info' ] = [
2009-10-16 03:01:55 +00:00
'group' => 'tokens' ,
2017-03-04 01:20:24 +00:00
];
$hooks [ 'token_info_alter' ] = [
2010-03-07 18:44:31 +00:00
'group' => 'tokens' ,
2017-03-04 01:20:24 +00:00
];
$hooks [ 'tokens' ] = [
2009-10-16 03:01:55 +00:00
'group' => 'tokens' ,
2017-03-04 01:20:24 +00:00
];
$hooks [ 'tokens_alter' ] = [
2010-10-20 16:44:45 +00:00
'group' => 'tokens' ,
2017-03-04 01:20:24 +00:00
];
2010-10-20 16:44:45 +00:00
2009-10-16 03:01:55 +00:00
return $hooks ;
}
2013-09-29 07:19:59 +00:00
/**
* Implements hook_theme_suggestions_HOOK () .
*/
function system_theme_suggestions_html ( array $variables ) {
2016-10-26 19:41:50 +00:00
$path_args = explode ( '/' , trim ( \Drupal :: service ( 'path.current' ) -> getPath (), '/' ));
2014-05-28 09:55:05 +00:00
return theme_get_suggestions ( $path_args , 'html' );
2013-09-29 07:19:59 +00:00
}
/**
* Implements hook_theme_suggestions_HOOK () .
*/
function system_theme_suggestions_page ( array $variables ) {
2016-10-26 19:41:50 +00:00
$path_args = explode ( '/' , trim ( \Drupal :: service ( 'path.current' ) -> getPath (), '/' ));
2019-08-22 01:17:06 +00:00
$suggestions = theme_get_suggestions ( $path_args , 'page' );
$http_error_suggestions = [
'system.401' => 'page__401' ,
'system.403' => 'page__403' ,
'system.404' => 'page__404' ,
];
$route_name = \Drupal :: routeMatch () -> getRouteName ();
if ( isset ( $http_error_suggestions [ $route_name ])) {
$suggestions [] = 'page__4xx' ;
$suggestions [] = $http_error_suggestions [ $route_name ];
}
return $suggestions ;
2013-09-29 07:19:59 +00:00
}
/**
* Implements hook_theme_suggestions_HOOK () .
*/
function system_theme_suggestions_maintenance_page ( array $variables ) {
2017-03-04 01:20:24 +00:00
$suggestions = [];
2013-09-29 07:19:59 +00:00
// Dead databases will show error messages so supplying this template will
// allow themers to override the page and the content completely.
$offline = defined ( 'MAINTENANCE_MODE' );
try {
2015-02-13 17:21:07 +00:00
\Drupal :: service ( 'path.matcher' ) -> isFrontPage ();
2013-09-29 07:19:59 +00:00
}
catch ( Exception $e ) {
// The database is not yet available.
$offline = TRUE ;
}
if ( $offline ) {
$suggestions [] = 'maintenance_page__offline' ;
}
return $suggestions ;
}
/**
* Implements hook_theme_suggestions_HOOK () .
*/
function system_theme_suggestions_region ( array $variables ) {
2017-03-04 01:20:24 +00:00
$suggestions = [];
2013-09-29 07:19:59 +00:00
if ( ! empty ( $variables [ 'elements' ][ '#region' ])) {
$suggestions [] = 'region__' . $variables [ 'elements' ][ '#region' ];
}
return $suggestions ;
}
2014-03-25 11:19:33 +00:00
/**
* Implements hook_theme_suggestions_HOOK () .
*/
function system_theme_suggestions_field ( array $variables ) {
2017-03-04 01:20:24 +00:00
$suggestions = [];
2014-03-25 11:19:33 +00:00
$element = $variables [ 'element' ];
$suggestions [] = 'field__' . $element [ '#field_type' ];
$suggestions [] = 'field__' . $element [ '#field_name' ];
$suggestions [] = 'field__' . $element [ '#entity_type' ] . '__' . $element [ '#bundle' ];
$suggestions [] = 'field__' . $element [ '#entity_type' ] . '__' . $element [ '#field_name' ];
$suggestions [] = 'field__' . $element [ '#entity_type' ] . '__' . $element [ '#field_name' ] . '__' . $element [ '#bundle' ];
return $suggestions ;
}
2016-03-14 09:21:48 +00:00
/**
* Prepares variables for the list of available bundles .
*
* Default template : entity - add - list . html . twig .
*
* @ param array $variables
* An associative array containing :
* - bundles : An array of bundles with the label , description , add_link keys .
* - add_bundle_message : The message shown when there are no bundles . Only
2016-04-07 12:49:26 +00:00
* available if the entity type uses bundle entities .
2016-03-14 09:21:48 +00:00
*/
function template_preprocess_entity_add_list ( & $variables ) {
foreach ( $variables [ 'bundles' ] as $bundle_name => $bundle_info ) {
$variables [ 'bundles' ][ $bundle_name ][ 'description' ] = [
'#markup' => $bundle_info [ 'description' ],
];
}
}
2009-10-15 21:19:31 +00:00
/**
2009-10-29 06:58:56 +00:00
* @ defgroup authorize Authorized operations
* @ {
* Functions to run operations with elevated privileges via authorize . php .
2009-10-15 21:19:31 +00:00
*
2009-10-29 06:58:56 +00:00
* Because of the Update manager functionality included in Drupal core , there
* is a mechanism for running operations with elevated file system privileges ,
* the top - level authorize . php script . This script runs at a reduced Drupal
* bootstrap level so that it is not reliant on the entire site being
* functional . The operations use a FileTransfer class to manipulate code
* installed on the system as the user that owns the files , not the user that
* the httpd is running as .
*
* The first setup is to define a callback function that should be authorized
* to run with the elevated privileges . This callback should take a
* FileTransfer as its first argument , although you can define an array of
* other arguments it should be invoked with . The callback should be placed in
* a separate . inc file that will be included by authorize . php .
*
* To run the operation , certain data must be saved into the SESSION , and then
* the flow of control should be redirected to the authorize . php script . There
* are two ways to do this , either to call system_authorized_run () directly ,
* or to call system_authorized_init () and then redirect to authorize . php ,
* using the URL from system_authorized_get_url () . Redirecting yourself is
* necessary when your authorized operation is being triggered by a form
Issue #1668866 by ParisLiakos, aspilicious, tim.plunkett, pdrake, g.oechsler, dawehner, Berdir, corvus_ch, damiankloip, disasm, marcingy, neclimdul: Replace drupal_goto() with RedirectResponse.
2013-06-19 16:07:30 +00:00
* submit handler , since calling redirecting in a submit handler is a bad
2014-08-07 20:43:27 +00:00
* idea , and you should instead use $form_state -> setRedirect () .
2009-10-29 06:58:56 +00:00
*
* Once the SESSION is setup for the operation and the user is redirected to
* authorize . php , they will be prompted for their connection credentials ( core
* provides FTP and SSH by default , although other connection classes can be
* added via contributed modules ) . With valid credentials , authorize . php will
* instantiate the appropriate FileTransfer object , and then invoke the
* desired operation passing in that object . The authorize . php script can act
* as a Batch API processing page , if the operation requires a batch .
*
* @ see authorize . php
2013-10-03 11:26:25 +00:00
* @ see \Drupal\Core\FileTransfer\FileTransfer
2010-12-01 00:23:36 +00:00
* @ see hook_filetransfer_info ()
2009-10-29 06:58:56 +00:00
*/
/**
* Setup a given callback to run via authorize . php with elevated privileges .
*
2020-02-20 21:38:33 +00:00
* To use authorize . php , certain variables must be stashed in the user ' s
* session . This function sets up all the necessary session variables . The
* calling function should then redirect to authorize . php , using the full path
* returned by system_authorized_get_url () . That initiates the workflow that
* will eventually lead to the callback being invoked . The callback will be
* invoked at a low bootstrap level , without all modules being invoked , so it
* needs to be careful not to assume any code exists .
* Example ( system_authorized_run ()) :
2012-11-07 15:23:29 +00:00
* @ code
* system_authorized_init ( $callback , $file , $arguments , $page_title );
2014-08-07 20:43:27 +00:00
* return new RedirectResponse ( system_authorized_get_url () -> toString ());
2012-11-07 15:23:29 +00:00
* @ endcode
* Example ( update_manager_install_form_submit ()) :
* @ code
* system_authorized_init ( 'update_authorize_run_install' ,
Issue #2347783 by kim.pepper, andypost, almaudoh, gumanist, aleevas, rodrigoaguilera, Berdir, saurabh-2k17, Spokje, dhirendra.mishra, alexpott, paulocs, izus, Wim Leers, KapilV, naveenvalecha, anmolgoyal74, subson, yo30, harsha012, mrinalini9, daffie, voleger, dww, fietserwin, tim.plunkett, joachim, larowlan: Deprecate drupal_get_path() and drupal_get_filename() and replace with ExtensionList::getPath() and ExtensionList::getPathname()
2021-07-15 10:20:33 +00:00
* \Drupal :: service ( 'extension.list.module' ) -> getPath ( 'update' ) . '/update.authorize.inc' ,
2012-11-07 15:23:29 +00:00
* $arguments , t ( 'Update manager' ));
2014-08-07 20:43:27 +00:00
* $form_state -> setRedirectUrl ( system_authorized_get_url ());
2012-11-07 15:23:29 +00:00
* @ endcode
2009-10-15 21:19:31 +00:00
*
2018-01-23 12:14:26 +00:00
* @ param callable $callback
2012-11-07 15:23:29 +00:00
* The name of the function to invoke once the user authorizes the operation .
2009-10-15 21:19:31 +00:00
* @ param $file
* The full path to the file where the callback function is implemented .
* @ param $arguments
* Optional array of arguments to pass into the callback when it is invoked .
* Note that the first argument to the callback is always the FileTransfer
* object created by authorize . php when the user authorizes the operation .
* @ param $page_title
* Optional string to use as the page title once redirected to authorize . php .
*/
2017-03-04 01:20:24 +00:00
function system_authorized_init ( $callback , $file , $arguments = [], $page_title = NULL ) {
2020-02-20 21:38:33 +00:00
$session = \Drupal :: request () -> getSession ();
2009-10-15 21:19:31 +00:00
// First, figure out what file transfer backends the site supports, and put
// all of those in the SESSION so that authorize.php has access to all of
// them via the class autoloader, even without a full bootstrap.
2020-02-20 21:38:33 +00:00
$session -> set ( 'authorize_filetransfer_info' , drupal_get_filetransfer_info ());
2009-10-15 21:19:31 +00:00
// Now, define the callback to invoke.
2020-02-20 21:38:33 +00:00
$session -> set ( 'authorize_operation' , [
2009-10-15 21:19:31 +00:00
'callback' => $callback ,
'file' => $file ,
'arguments' => $arguments ,
2020-02-20 21:38:33 +00:00
]);
2009-10-15 21:19:31 +00:00
if ( isset ( $page_title )) {
2020-02-20 21:38:33 +00:00
$session -> set ( 'authorize_page_title' , $page_title );
2009-10-15 21:19:31 +00:00
}
2009-10-29 06:58:56 +00:00
}
2009-10-15 21:19:31 +00:00
2009-10-29 06:58:56 +00:00
/**
* Return the URL for the authorize . php script .
2009-11-01 23:02:13 +00:00
*
* @ param array $options
2016-03-10 16:05:49 +00:00
* Optional array of options to set on the \Drupal\Core\Url object .
2020-05-20 22:11:54 +00:00
*
2014-08-07 20:43:27 +00:00
* @ return \Drupal\Core\Url
2012-09-02 04:50:06 +00:00
* The full URL to authorize . php , using HTTPS if available .
2012-11-07 15:23:29 +00:00
*
* @ see system_authorized_init ()
2009-10-29 06:58:56 +00:00
*/
2017-03-04 01:20:24 +00:00
function system_authorized_get_url ( array $options = []) {
2015-02-11 03:59:05 +00:00
// core/authorize.php is an unrouted URL, so using the base: scheme is
// the correct usage for this case.
2015-01-30 23:15:21 +00:00
$url = Url :: fromUri ( 'base:core/authorize.php' );
2014-08-07 20:43:27 +00:00
$url_options = $url -> getOptions ();
$url -> setOptions ( $options + $url_options );
return $url ;
2009-10-15 21:19:31 +00:00
}
2011-07-28 19:06:04 +00:00
/**
* Returns the URL for the authorize . php script when it is processing a batch .
Issue #1668866 by ParisLiakos, aspilicious, tim.plunkett, pdrake, g.oechsler, dawehner, Berdir, corvus_ch, damiankloip, disasm, marcingy, neclimdul: Replace drupal_goto() with RedirectResponse.
2013-06-19 16:07:30 +00:00
*
* @ param array $options
2016-03-10 16:05:49 +00:00
* Optional array of options to set on the \Drupal\Core\Url object .
2014-08-07 20:43:27 +00:00
*
* @ return \Drupal\Core\Url
2011-07-28 19:06:04 +00:00
*/
2017-03-04 01:20:24 +00:00
function system_authorized_batch_processing_url ( array $options = []) {
$options [ 'query' ] = [ 'batch' => '1' ];
Issue #1668866 by ParisLiakos, aspilicious, tim.plunkett, pdrake, g.oechsler, dawehner, Berdir, corvus_ch, damiankloip, disasm, marcingy, neclimdul: Replace drupal_goto() with RedirectResponse.
2013-06-19 16:07:30 +00:00
return system_authorized_get_url ( $options );
2011-07-28 19:06:04 +00:00
}
2009-10-29 06:58:56 +00:00
/**
* Setup and invoke an operation using authorize . php .
*
2010-01-30 07:54:01 +00:00
* @ see system_authorized_init ()
2009-10-29 06:58:56 +00:00
*/
2017-03-04 01:20:24 +00:00
function system_authorized_run ( $callback , $file , $arguments = [], $page_title = NULL ) {
2009-10-29 06:58:56 +00:00
system_authorized_init ( $callback , $file , $arguments , $page_title );
2014-08-07 20:43:27 +00:00
return new RedirectResponse ( system_authorized_get_url () -> toString ());
2009-10-29 06:58:56 +00:00
}
2009-11-01 23:02:13 +00:00
/**
* Use authorize . php to run batch_process () .
*
* @ see batch_process ()
*/
function system_authorized_batch_process () {
$finish_url = system_authorized_get_url ();
2011-07-28 19:06:04 +00:00
$process_url = system_authorized_batch_processing_url ();
Issue #2042447 by David_Rothstein, joelpittet, stefan.r, SebCorbin, mpdonadio, steinmb, webchick, Cottser, miniwebs2, Vj, Gilbert Rehling, nuwe, yched, StuartJNCC, Fabianx, yktdan, herom: Install a module user interface does not install modules (or themes)
2015-08-07 09:02:58 +00:00
return batch_process ( $finish_url -> setAbsolute () -> toString (), $process_url );
2009-11-01 23:02:13 +00:00
}
2009-10-29 06:58:56 +00:00
/**
* @ } End of " defgroup authorize " .
*/
2009-10-15 21:19:31 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_updater_info () .
2009-10-15 21:19:31 +00:00
*/
function system_updater_info () {
2017-03-04 01:20:24 +00:00
return [
'module' => [
2012-03-11 00:23:05 +00:00
'class' => 'Drupal\Core\Updater\Module' ,
2009-10-15 21:19:31 +00:00
'name' => t ( 'Update modules' ),
'weight' => 0 ,
2017-03-04 01:20:24 +00:00
],
'theme' => [
2012-03-11 00:23:05 +00:00
'class' => 'Drupal\Core\Updater\Theme' ,
2009-10-15 21:19:31 +00:00
'name' => t ( 'Update themes' ),
'weight' => 0 ,
2017-03-04 01:20:24 +00:00
],
];
2009-10-15 21:19:31 +00:00
}
2009-06-23 12:11:19 +00:00
/**
2010-12-01 00:23:36 +00:00
* Implements hook_filetransfer_info () .
2009-06-23 12:11:19 +00:00
*/
2010-12-01 00:23:36 +00:00
function system_filetransfer_info () {
2017-03-04 01:20:24 +00:00
$backends = [];
2009-06-23 12:11:19 +00:00
2009-10-24 05:38:28 +00:00
// This is the default, will be available on most systems.
2010-10-05 02:08:53 +00:00
if ( function_exists ( 'ftp_connect' )) {
2017-03-04 01:20:24 +00:00
$backends [ 'ftp' ] = [
2009-07-01 13:44:53 +00:00
'title' => t ( 'FTP' ),
2012-04-03 06:12:03 +00:00
'class' => 'Drupal\Core\FileTransfer\FTP' ,
2009-07-01 13:44:53 +00:00
'weight' => 0 ,
2017-03-04 01:20:24 +00:00
];
2009-06-23 12:11:19 +00:00
}
2009-08-24 00:14:23 +00:00
2009-07-01 13:44:53 +00:00
// SSH2 lib connection is only available if the proper PHP extension is
// installed.
if ( function_exists ( 'ssh2_connect' )) {
2017-03-04 01:20:24 +00:00
$backends [ 'ssh' ] = [
2009-07-01 13:44:53 +00:00
'title' => t ( 'SSH' ),
2012-04-03 06:12:03 +00:00
'class' => 'Drupal\Core\FileTransfer\SSH' ,
2009-07-01 13:44:53 +00:00
'weight' => 20 ,
2017-03-04 01:20:24 +00:00
];
2009-06-23 12:11:19 +00:00
}
return $backends ;
}
2012-12-13 12:23:00 +00:00
/**
2014-10-16 12:36:06 +00:00
* Implements hook_page_attachments () .
2013-12-15 17:57:31 +00:00
*
* @ see template_preprocess_maintenance_page ()
2015-04-28 15:44:27 +00:00
* @ see \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter
2012-12-13 12:23:00 +00:00
*/
2014-10-16 12:36:06 +00:00
function system_page_attachments ( array & $page ) {
2013-12-15 17:57:31 +00:00
// Ensure the same CSS is loaded in template_preprocess_maintenance_page().
2014-03-09 19:59:45 +00:00
$page [ '#attached' ][ 'library' ][] = 'system/base' ;
2014-03-21 12:35:45 +00:00
if ( \Drupal :: service ( 'router.admin_context' ) -> isAdminRoute ()) {
2014-03-09 19:59:45 +00:00
$page [ '#attached' ][ 'library' ][] = 'system/admin' ;
2012-12-13 12:23:00 +00:00
}
2014-01-23 18:04:41 +00:00
2014-11-26 10:37:53 +00:00
// Attach libraries used by this theme.
2014-11-14 10:43:20 +00:00
$active_theme = \Drupal :: theme () -> getActiveTheme ();
foreach ( $active_theme -> getLibraries () as $library ) {
$page [ '#attached' ][ 'library' ][] = $library ;
}
// Attach favicon.
if ( theme_get_setting ( 'features.favicon' )) {
$favicon = theme_get_setting ( 'favicon.url' );
$type = theme_get_setting ( 'favicon.mimetype' );
2017-03-04 01:20:24 +00:00
$page [ '#attached' ][ 'html_head_link' ][][] = [
2021-06-28 11:04:53 +00:00
'rel' => 'icon' ,
2014-11-14 10:43:20 +00:00
'href' => UrlHelper :: stripDangerousProtocols ( $favicon ),
'type' => $type ,
2017-03-04 01:20:24 +00:00
];
2014-11-14 10:43:20 +00:00
}
// Get the major Drupal version.
2021-11-15 02:35:55 +00:00
[ $version ] = explode ( '.' , \Drupal :: VERSION );
2014-11-14 10:43:20 +00:00
// Attach default meta tags.
2017-03-04 01:20:24 +00:00
$meta_default = [
2014-11-14 10:43:20 +00:00
// Make sure the Content-Type comes first because the IE browser may be
// vulnerable to XSS via encoding attacks from any content that comes
// before this META tag, such as a TITLE tag.
2017-03-04 01:20:24 +00:00
'system_meta_content_type' => [
2014-11-14 10:43:20 +00:00
'#tag' => 'meta' ,
2017-03-04 01:20:24 +00:00
'#attributes' => [
2014-11-14 10:43:20 +00:00
'charset' => 'utf-8' ,
2017-03-04 01:20:24 +00:00
],
2014-11-14 10:43:20 +00:00
// Security: This always has to be output first.
'#weight' => - 1000 ,
2017-03-04 01:20:24 +00:00
],
2014-11-14 10:43:20 +00:00
// Show Drupal and the major version number in the META GENERATOR tag.
2017-03-04 01:20:24 +00:00
'system_meta_generator' => [
2014-11-14 10:43:20 +00:00
'#type' => 'html_tag' ,
'#tag' => 'meta' ,
2017-03-04 01:20:24 +00:00
'#attributes' => [
2014-11-14 10:43:20 +00:00
'name' => 'Generator' ,
2015-05-18 21:08:10 +00:00
'content' => 'Drupal ' . $version . ' (https://www.drupal.org)' ,
2017-03-04 01:20:24 +00:00
],
],
2014-11-14 10:43:20 +00:00
// Attach default mobile meta tags for responsive design.
2017-03-04 01:20:24 +00:00
'MobileOptimized' => [
2014-11-14 10:43:20 +00:00
'#tag' => 'meta' ,
2017-03-04 01:20:24 +00:00
'#attributes' => [
2014-11-14 10:43:20 +00:00
'name' => 'MobileOptimized' ,
'content' => 'width' ,
2017-03-04 01:20:24 +00:00
],
],
'HandheldFriendly' => [
2014-11-14 10:43:20 +00:00
'#tag' => 'meta' ,
2017-03-04 01:20:24 +00:00
'#attributes' => [
2014-11-14 10:43:20 +00:00
'name' => 'HandheldFriendly' ,
'content' => 'true' ,
2017-03-04 01:20:24 +00:00
],
],
'viewport' => [
2014-11-14 10:43:20 +00:00
'#tag' => 'meta' ,
2017-03-04 01:20:24 +00:00
'#attributes' => [
2014-11-14 10:43:20 +00:00
'name' => 'viewport' ,
'content' => 'width=device-width, initial-scale=1.0' ,
2017-03-04 01:20:24 +00:00
],
],
];
2014-11-14 10:43:20 +00:00
foreach ( $meta_default as $key => $value ) {
$page [ '#attached' ][ 'html_head' ][] = [ $value , $key ];
}
2014-01-23 18:04:41 +00:00
// Handle setting the "active" class on links by:
// - loading the active-link library if the current user is authenticated;
2015-04-28 15:44:27 +00:00
// - applying a response filter if the current user is anonymous.
2016-10-15 05:42:50 +00:00
// @see \Drupal\Core\Link
2014-01-23 18:04:41 +00:00
// @see \Drupal\Core\Utility\LinkGenerator::generate()
2014-02-07 04:28:14 +00:00
// @see template_preprocess_links()
2015-04-28 15:44:27 +00:00
// @see \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter
2014-01-23 18:04:41 +00:00
if ( \Drupal :: currentUser () -> isAuthenticated ()) {
2014-03-09 19:59:45 +00:00
$page [ '#attached' ][ 'library' ][] = 'core/drupal.active-link' ;
2014-01-23 18:04:41 +00:00
}
2010-09-05 02:21:38 +00:00
}
2015-06-20 17:16:07 +00:00
/**
* Implements hook_js_settings_build () .
*
* Sets values for the core / drupal . ajax library , which just depends on the
* active theme but no other request - dependent values .
*/
function system_js_settings_build ( & $settings , AttachedAssetsInterface $assets ) {
// Generate the values for the core/drupal.ajax library.
// We need to send ajaxPageState settings for core/drupal.ajax if:
// - ajaxPageState is being loaded in this Response, in which case it will
// already exist at $settings['ajaxPageState'] (because the core/drupal.ajax
// library definition specifies a placeholder 'ajaxPageState' setting).
// - core/drupal.ajax already has been loaded and hence this is an AJAX
// Response in which we must send the list of extra asset libraries that are
// being added in this AJAX Response.
/** @var \Drupal\Core\Asset\LibraryDependencyResolver $library_dependency_resolver */
$library_dependency_resolver = \Drupal :: service ( 'library.dependency_resolver' );
if ( isset ( $settings [ 'ajaxPageState' ]) || in_array ( 'core/drupal.ajax' , $library_dependency_resolver -> getLibrariesWithDependencies ( $assets -> getAlreadyLoadedLibraries ()))) {
// Provide the page with information about the theme that's used, so that
// a later AJAX request can be rendered using the same theme.
// @see \Drupal\Core\Theme\AjaxBasePageNegotiator
$theme_key = \Drupal :: theme () -> getActiveTheme () -> getName ();
$settings [ 'ajaxPageState' ][ 'theme' ] = $theme_key ;
}
}
2014-12-04 11:37:23 +00:00
/**
* Implements hook_js_settings_alter () .
*
2015-06-20 17:16:07 +00:00
* Sets values which depend on the current request , like core / drupalSettings
* as well as theme_token ajax state .
2014-12-04 11:37:23 +00:00
*/
2015-01-21 15:21:06 +00:00
function system_js_settings_alter ( & $settings , AttachedAssetsInterface $assets ) {
2021-05-27 12:47:21 +00:00
// As this is being output in the final response always use the main request.
$request = \Drupal :: requestStack () -> getMainRequest ();
2014-12-04 11:37:23 +00:00
$current_query = $request -> query -> all ();
2015-07-24 14:08:23 +00:00
// Let output path processors set a prefix.
/** @var \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor */
$path_processor = \Drupal :: service ( 'path_processor_manager' );
$options = [ 'prefix' => '' ];
$path_processor -> processOutbound ( '/' , $options );
$pathPrefix = $options [ 'prefix' ];
2016-01-05 05:56:08 +00:00
$route_match = \Drupal :: routeMatch ();
if ( $route_match instanceof StackedRouteMatchInterface ) {
$route_match = $route_match -> getMasterRouteMatch ();
}
$current_path = $route_match -> getRouteName () ? Url :: fromRouteMatch ( $route_match ) -> getInternalPath () : '' ;
$current_path_is_admin = \Drupal :: service ( 'router.admin_context' ) -> isAdminRoute ( $route_match -> getRouteObject ());
2014-12-04 11:37:23 +00:00
$path_settings = [
'baseUrl' => $request -> getBaseUrl () . '/' ,
'pathPrefix' => $pathPrefix ,
'currentPath' => $current_path ,
'currentPathIsAdmin' => $current_path_is_admin ,
2015-02-13 17:21:07 +00:00
'isFront' => \Drupal :: service ( 'path.matcher' ) -> isFrontPage (),
2014-12-04 11:37:23 +00:00
'currentLanguage' => \Drupal :: languageManager () -> getCurrentLanguage ( LanguageInterface :: TYPE_URL ) -> getId (),
];
if ( ! empty ( $current_query )) {
ksort ( $current_query );
$path_settings [ 'currentQuery' ] = ( object ) $current_query ;
}
// Only set core/drupalSettings values that haven't been set already.
foreach ( $path_settings as $key => $value ) {
if ( ! isset ( $settings [ 'path' ][ $key ])) {
$settings [ 'path' ][ $key ] = $value ;
}
}
2015-02-19 09:56:00 +00:00
if ( ! isset ( $settings [ 'pluralDelimiter' ])) {
2018-11-19 11:59:53 +00:00
$settings [ 'pluralDelimiter' ] = PoItem :: DELIMITER ;
2014-12-04 11:37:23 +00:00
}
2015-06-20 17:16:07 +00:00
// Add the theme token to ajaxPageState, ensuring the database is available
2016-09-26 07:46:29 +00:00
// before doing so. Also add the loaded libraries to ajaxPageState.
2015-01-21 15:21:06 +00:00
/** @var \Drupal\Core\Asset\LibraryDependencyResolver $library_dependency_resolver */
$library_dependency_resolver = \Drupal :: service ( 'library.dependency_resolver' );
if ( isset ( $settings [ 'ajaxPageState' ]) || in_array ( 'core/drupal.ajax' , $library_dependency_resolver -> getLibrariesWithDependencies ( $assets -> getAlreadyLoadedLibraries ()))) {
if ( ! defined ( 'MAINTENANCE_MODE' )) {
2015-07-28 13:46:57 +00:00
// The theme token is only validated when the theme requested is not the
// default, so don't generate it unless necessary.
// @see \Drupal\Core\Theme\AjaxBasePageNegotiator::determineActiveTheme()
$active_theme_key = \Drupal :: theme () -> getActiveTheme () -> getName ();
if ( $active_theme_key !== \Drupal :: service ( 'theme_handler' ) -> getDefault ()) {
$settings [ 'ajaxPageState' ][ 'theme_token' ] = \Drupal :: csrfToken ()
-> get ( $active_theme_key );
}
2015-01-21 15:21:06 +00:00
}
2016-09-26 07:46:29 +00:00
// Provide the page with information about the individual asset libraries
// used, information not otherwise available when aggregation is enabled.
2018-05-07 20:11:35 +00:00
$minimal_libraries = $library_dependency_resolver -> getMinimalRepresentativeSubset ( array_unique ( array_merge (
2016-09-26 07:46:29 +00:00
$assets -> getLibraries (),
$assets -> getAlreadyLoadedLibraries ()
2018-05-07 20:11:35 +00:00
)));
2016-09-26 07:46:29 +00:00
sort ( $minimal_libraries );
$settings [ 'ajaxPageState' ][ 'libraries' ] = implode ( ',' , $minimal_libraries );
2015-01-21 15:21:06 +00:00
}
2014-12-04 11:37:23 +00:00
}
2015-07-03 19:52:58 +00:00
/**
* Implements hook_form_alter () .
*/
function system_form_alter ( & $form , FormStateInterface $form_state ) {
// If the page that's being built is cacheable, set the 'immutable' flag, to
// ensure that when the form is used, a new form build ID is generated when
// appropriate, to prevent information disclosure.
// Note: This code just wants to know whether cache response headers are set,
// not whether page_cache module will be active.
// \Drupal\Core\EventSubscriber\FinishResponseSubscriber::onRespond will
// send those headers, in case $request_policy->check($request) succeeds. In
// that case we need to ensure that the immutable flag is sot, so future POST
// request won't take over the form state of another user.
/** @var \Drupal\Core\PageCache\RequestPolicyInterface $request_policy */
$request_policy = \Drupal :: service ( 'page_cache_request_policy' );
$request = \Drupal :: requestStack () -> getCurrentRequest ();
$request_is_cacheable = $request_policy -> check ( $request ) === RequestPolicyInterface :: ALLOW ;
if ( $request_is_cacheable ) {
$form_state -> addBuildInfo ( 'immutable' , TRUE );
}
}
2007-10-17 15:24:56 +00:00
/**
2013-10-03 20:55:34 +00:00
* Implements hook_preprocess_HOOK () for block templates .
2008-12-16 23:57:33 +00:00
*/
Issue #1535868 by EclipseGc, tim.plunkett, xjm, Jody Lynn, sdboyer, naxoc, tizzo, effulgentsia, dawehner, disasm, beejeebus: Convert all blocks into plugins.
2013-01-04 17:05:13 +00:00
function system_preprocess_block ( & $variables ) {
2013-12-19 17:57:48 +00:00
switch ( $variables [ 'base_plugin_id' ]) {
2014-03-03 16:38:08 +00:00
case 'system_branding_block' :
$variables [ 'site_logo' ] = '' ;
if ( $variables [ 'content' ][ 'site_logo' ][ '#access' ] && $variables [ 'content' ][ 'site_logo' ][ '#uri' ]) {
$variables [ 'site_logo' ] = $variables [ 'content' ][ 'site_logo' ][ '#uri' ];
}
$variables [ 'site_name' ] = '' ;
if ( $variables [ 'content' ][ 'site_name' ][ '#access' ] && $variables [ 'content' ][ 'site_name' ][ '#markup' ]) {
$variables [ 'site_name' ] = $variables [ 'content' ][ 'site_name' ][ '#markup' ];
}
$variables [ 'site_slogan' ] = '' ;
if ( $variables [ 'content' ][ 'site_slogan' ][ '#access' ] && $variables [ 'content' ][ 'site_slogan' ][ '#markup' ]) {
2017-01-11 16:08:02 +00:00
$variables [ 'site_slogan' ] = [
'#markup' => $variables [ 'content' ][ 'site_slogan' ][ '#markup' ],
];
2014-03-03 16:38:08 +00:00
}
break ;
2009-03-20 19:18:11 +00:00
}
2007-10-17 15:24:56 +00:00
}
2005-11-13 07:57:11 +00:00
/**
2010-10-05 06:23:18 +00:00
* Checks the existence of the directory specified in $form_element .
*
* This function is called from the system_settings form to check all core
* file directories ( file_public_path , file_private_path , file_temporary_path ) .
2005-11-13 07:57:11 +00:00
*
* @ param $form_element
* The form element containing the name of the directory to check .
2014-08-22 01:04:33 +00:00
* @ param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form .
2005-11-13 07:57:11 +00:00
*/
2014-08-22 01:04:33 +00:00
function system_check_directory ( $form_element , FormStateInterface $form_state ) {
2009-08-17 19:14:42 +00:00
$directory = $form_element [ '#value' ];
2010-04-30 01:33:17 +00:00
if ( strlen ( $directory ) == 0 ) {
return $form_element ;
}
2009-08-24 00:14:23 +00:00
2014-06-26 18:55:12 +00:00
$logger = \Drupal :: logger ( 'file system' );
2019-03-07 09:12:01 +00:00
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal :: service ( 'file_system' );
if ( ! is_dir ( $directory ) && ! $file_system -> mkdir ( $directory , NULL , TRUE )) {
2018-05-17 10:41:17 +00:00
// If the directory does not exist and cannot be created.
2017-03-04 01:20:24 +00:00
$form_state -> setErrorByName ( $form_element [ '#parents' ][ 0 ], t ( 'The directory %directory does not exist and could not be created.' , [ '%directory' => $directory ]));
$logger -> error ( 'The directory %directory does not exist and could not be created.' , [ '%directory' => $directory ]);
2009-08-17 19:14:42 +00:00
}
2019-03-07 09:12:01 +00:00
if ( is_dir ( $directory ) && ! is_writable ( $directory ) && ! $file_system -> chmod ( $directory )) {
2010-01-25 10:38:35 +00:00
// If the directory is not writable and cannot be made so.
2017-03-04 01:20:24 +00:00
$form_state -> setErrorByName ( $form_element [ '#parents' ][ 0 ], t ( 'The directory %directory exists but is not writable and could not be made writable.' , [ '%directory' => $directory ]));
$logger -> error ( 'The directory %directory exists but is not writable and could not be made writable.' , [ '%directory' => $directory ]);
2009-08-17 19:14:42 +00:00
}
2010-04-30 01:33:17 +00:00
elseif ( is_dir ( $directory )) {
2009-08-17 19:14:42 +00:00
if ( $form_element [ '#name' ] == 'file_public_path' ) {
// Create public .htaccess file.
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
FileSecurity :: writeHtaccess ( $directory , FALSE );
2009-08-17 19:14:42 +00:00
}
else {
// Create private .htaccess file.
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
FileSecurity :: writeHtaccess ( $directory );
2009-08-17 19:14:42 +00:00
}
}
2005-11-13 07:57:11 +00:00
return $form_element ;
}
2005-08-16 18:06:18 +00:00
/**
* Get a list of available regions from a specified theme .
*
2014-04-22 18:37:12 +00:00
* @ param \Drupal\Core\Extension\Extension | string $theme
* A theme extension object , or the name of a theme .
2009-07-18 02:36:01 +00:00
* @ param $show
* Possible values : REGIONS_ALL or REGIONS_VISIBLE . Visible excludes hidden
* regions .
2020-05-20 22:11:54 +00:00
*
Issue #2941148 by quietone, bruno.bicudo, ravi.shankar, Sweetchuck, beatrizrodrigues, lucienchalom, VitaliyB98, WagnerMelo, sophiavs, ankitjain28may, daffie, longwave, Sutharsan, borisson_, cosmicdreams, heykarthikwithu, catch: Fix Drupal.Commenting.FunctionComment.MissingReturnType
2022-09-27 09:58:26 +00:00
* @ return string []
2005-08-16 18:06:18 +00:00
* An array of regions in the form $region [ 'name' ] = 'description' .
*/
2014-04-22 18:37:12 +00:00
function system_region_list ( $theme , $show = REGIONS_ALL ) {
if ( ! $theme instanceof Extension ) {
$themes = \Drupal :: service ( 'theme_handler' ) -> listInfo ();
if ( ! isset ( $themes [ $theme ])) {
2017-03-04 01:20:24 +00:00
return [];
2014-04-22 18:37:12 +00:00
}
$theme = $themes [ $theme ];
2010-10-01 18:37:23 +00:00
}
2017-03-04 01:20:24 +00:00
$list = [];
2014-04-22 18:37:12 +00:00
$info = $theme -> info ;
2010-10-01 18:37:23 +00:00
// If requested, suppress hidden regions. See block_admin_display_form().
foreach ( $info [ 'regions' ] as $name => $label ) {
if ( $show == REGIONS_ALL || ! isset ( $info [ 'regions_hidden' ]) || ! in_array ( $name , $info [ 'regions_hidden' ])) {
2011-04-10 16:25:06 +00:00
$list [ $name ] = t ( $label );
2009-07-18 02:36:01 +00:00
}
2005-08-16 18:06:18 +00:00
}
2010-10-01 18:37:23 +00:00
return $list ;
2009-07-18 02:36:01 +00:00
}
2005-08-16 18:06:18 +00:00
2014-01-08 08:39:51 +00:00
/**
2014-06-06 20:01:38 +00:00
* Sorts themes by their names , with the default theme listed first .
2014-06-02 17:19:28 +00:00
*
* Callback for uasort () within
* \Drupal\system\Controller\SystemController :: themesPage () .
*
2021-08-06 07:01:36 +00:00
* @ see \Drupal\Core\Extension\Extension :: sortByName ()
2014-01-08 08:39:51 +00:00
*/
function system_sort_themes ( $a , $b ) {
if ( $a -> is_default ) {
return - 1 ;
}
if ( $b -> is_default ) {
return 1 ;
}
return strcasecmp ( $a -> info [ 'name' ], $b -> info [ 'name' ]);
}
2009-07-18 02:36:01 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_system_info_alter () .
2009-07-18 02:36:01 +00:00
*/
2014-03-11 17:19:24 +00:00
function system_system_info_alter ( & $info , Extension $file , $type ) {
2012-01-31 07:53:00 +00:00
// Remove page-top and page-bottom from the blocks UI since they are reserved for
// modules to populate from outside the blocks system.
2009-09-25 23:48:24 +00:00
if ( $type == 'theme' ) {
$info [ 'regions_hidden' ][] = 'page_top' ;
$info [ 'regions_hidden' ][] = 'page_bottom' ;
}
2005-08-16 18:06:18 +00:00
}
/**
2012-11-29 07:37:55 +00:00
* Gets the name of the default region for a given theme .
2005-08-16 18:06:18 +00:00
*
* @ param $theme
* The name of a theme .
2020-05-20 22:11:54 +00:00
*
Issue #2941148 by quietone, bruno.bicudo, ravi.shankar, Sweetchuck, beatrizrodrigues, lucienchalom, VitaliyB98, WagnerMelo, sophiavs, ankitjain28may, daffie, longwave, Sutharsan, borisson_, cosmicdreams, heykarthikwithu, catch: Fix Drupal.Commenting.FunctionComment.MissingReturnType
2022-09-27 09:58:26 +00:00
* @ return string
2005-08-16 18:06:18 +00:00
* A string that is the region name .
*/
function system_default_region ( $theme ) {
2010-05-17 21:08:37 +00:00
$regions = array_keys ( system_region_list ( $theme , REGIONS_VISIBLE ));
2021-11-15 02:19:43 +00:00
return $regions [ 0 ] ? ? '' ;
2005-08-16 18:06:18 +00:00
}
2006-07-31 11:25:55 +00:00
/**
2012-01-27 15:37:10 +00:00
* Determines whether the current user is in compact mode .
*
* Compact mode shows certain administration pages with less description text ,
* such as the configuration page and the permissions page .
*
* Whether the user is in compact mode is determined by a cookie , which is set
2013-08-16 23:18:07 +00:00
* for the user by \Drupal\system\Controller\SystemController :: compactPage () .
2012-01-27 15:37:10 +00:00
*
* If the user does not have the cookie , the default value is given by the
2015-12-10 14:19:31 +00:00
* configuration variable 'system.site.admin_compact_mode' , which itself
* defaults to FALSE . This does not have a user interface to set it : it is a
* hidden variable which can be set in the settings . php file .
2010-04-06 06:00:05 +00:00
*
2013-08-16 23:18:07 +00:00
* @ return bool
2010-04-06 06:00:05 +00:00
* TRUE when in compact mode , FALSE when in expanded mode .
2006-07-31 11:25:55 +00:00
*/
function system_admin_compact_mode () {
2010-04-06 06:00:05 +00:00
// PHP converts dots into underscores in cookie names to avoid problems with
// its parser, so we use a converted cookie name.
2013-12-05 18:02:36 +00:00
return \Drupal :: request () -> cookies -> get ( 'Drupal_visitor_admin_compact_mode' , \Drupal :: config ( 'system.site' ) -> get ( 'admin_compact_mode' ));
2006-07-31 11:25:55 +00:00
}
2007-12-16 21:01:45 +00:00
/**
* Generate a list of tasks offered by a specified module .
*
2014-03-28 23:27:34 +00:00
* @ param string $module
2007-12-16 21:01:45 +00:00
* Module name .
2023-05-22 11:11:30 +00:00
* @ param string | array $module_name
* The module ' s display name . Passing information , as provided by
* \Drupal :: service ( 'extension.list.module' ) -> getExtensionInfo () is
* deprecated in drupal : 10.2 . 0. Pass only $info [ " name " ] instead .
2010-10-01 15:24:18 +00:00
*
2014-03-28 23:27:34 +00:00
* @ return array
2007-12-16 21:01:45 +00:00
* An array of task links .
*/
2023-05-22 11:11:30 +00:00
function system_get_module_admin_tasks ( $module , string | array $module_name ) {
if ( ! is_string ( $module_name )) {
@ trigger_error ( 'Calling ' . __FUNCTION__ . '() with $module_name argument as array is deprecated in drupal:10.2.0 and is required to be string from drupal:11.0.0. Pass only $info["name"] instead. See https://www.drupal.org/node/3357711' , E_USER_DEPRECATED );
$module_name = $module_name [ 'name' ];
}
2014-07-30 12:04:04 +00:00
$tree = & drupal_static ( __FUNCTION__ );
$menu_tree = \Drupal :: menuTree ();
if ( ! isset ( $tree )) {
$parameters = new MenuTreeParameters ();
2014-08-12 19:30:35 +00:00
$parameters -> setRoot ( 'system.admin' ) -> excludeRoot () -> onlyEnabledLinks ();
2014-07-30 12:04:04 +00:00
$tree = $menu_tree -> load ( 'system.admin' , $parameters );
2017-03-04 01:20:24 +00:00
$manipulators = [
[ 'callable' => 'menu.default_tree_manipulators:checkAccess' ],
[ 'callable' => 'menu.default_tree_manipulators:generateIndexAndSort' ],
[ 'callable' => 'menu.default_tree_manipulators:flatten' ],
];
2014-07-30 12:04:04 +00:00
$tree = $menu_tree -> transform ( $tree , $manipulators );
2007-08-09 20:05:49 +00:00
}
2008-09-16 18:08:59 +00:00
2017-03-04 01:20:24 +00:00
$admin_tasks = [];
2014-07-30 12:04:04 +00:00
foreach ( $tree as $element ) {
Issue #1805054 by Wim Leers, Gábor Hojtsy, effulgentsia, jibran, jessebeach, catch, dawehner, Fabianx, sun, larowlan: Cache localized, access filtered, URL resolved, and rendered menu trees
2015-05-26 21:22:31 +00:00
if ( ! $element -> access -> isAllowed ()) {
// @todo Bubble cacheability metadata of both accessible and inaccessible
// links. Currently made impossible by the way admin tasks are rendered.
continue ;
}
2014-07-30 12:04:04 +00:00
$link = $element -> link ;
if ( $link -> getProvider () != $module ) {
2014-03-28 23:27:34 +00:00
continue ;
}
2017-03-04 01:20:24 +00:00
$admin_tasks [] = [
2014-07-30 12:04:04 +00:00
'title' => $link -> getTitle (),
'description' => $link -> getDescription (),
'url' => $link -> getUrlObject (),
2017-03-04 01:20:24 +00:00
];
2006-11-21 20:14:19 +00:00
}
2010-10-01 15:24:18 +00:00
// Append link for permissions.
2014-09-18 07:41:29 +00:00
/** @var \Drupal\user\PermissionHandlerInterface $permission_handler */
$permission_handler = \Drupal :: service ( 'user.permissions' );
if ( $permission_handler -> moduleProvidesPermissions ( $module )) {
2014-07-29 08:48:31 +00:00
/** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */
2014-02-24 19:38:23 +00:00
$access_manager = \Drupal :: service ( 'access_manager' );
2021-10-18 12:08:44 +00:00
if ( $access_manager -> checkNamedRoute ( 'user.admin_permissions.module' , [ 'modules' => $module ], \Drupal :: currentUser ())) {
2014-07-30 12:04:04 +00:00
/** @var \Drupal\Core\Url $url */
2021-10-18 12:08:44 +00:00
$url = new Url ( 'user.admin_permissions.module' , [ 'modules' => $module ]);
2017-03-04 01:20:24 +00:00
$admin_tasks [ " user.admin_permissions. $module " ] = [
2023-05-22 11:11:30 +00:00
'title' => t ( 'Configure @module permissions' , [ '@module' => $module_name ]),
2014-07-30 12:04:04 +00:00
'description' => '' ,
'url' => $url ,
2017-03-04 01:20:24 +00:00
];
2006-11-21 20:14:19 +00:00
}
}
return $admin_tasks ;
}
2007-04-10 10:10:27 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_cron () .
2007-04-10 10:10:27 +00:00
*
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
* Remove older rows from flood , batch cache and expirable keyvalue tables . Also
* ensure files directories have . htaccess files .
2007-04-10 10:10:27 +00:00
*/
function system_cron () {
2014-12-04 12:31:10 +00:00
// Clean up the flood.
2014-04-06 20:34:23 +00:00
\Drupal :: flood () -> garbageCollection ();
2007-05-30 08:08:59 +00:00
2013-03-22 09:36:55 +00:00
foreach ( Cache :: getBins () as $cache_backend ) {
$cache_backend -> garbageCollection ();
2008-10-06 23:02:08 +00:00
}
- Patch #391340 by chx, dww, neclimdul, Crell, alex_b, et al: job queue API.
The queue system allows placing items in a queue and processing them later. The system tries to ensure that only one consumer can process an item.
Before a queue can be used it needs to be created by DrupalQueueInterface::createQueue().
Items can be added to the queue by passing an arbitrary data object to DrupalQueueInterface::createItem().
To process an item, call DrupalQueueInterface::claimItem() and specify how long you want to have a lease for working on that item. When finished processing, the item needs to be deleted by calling DrupalQueueInterface::deleteItem(). If the consumer dies, the item will be made available again by the DrapalQueueInterface implementation once the lease expires. Another consumer will then be able to receive it when calling DrupalQueueInterface::claimItem().
The $item object used by the DrupalQueueInterface can contain arbitrary metadata depending on the implementation. Systems using the interface should only rely on the data property which will contain the information passed to DrupalQueueInterface::createItem(). The full queue item returned by DrupalQueueInterface::createItem() needs to be passed to DrupalQueueInterface::deleteItem() once processing is completed.
While the queue system makes a best effort to preserve order in messages, due to the pluggable nature of the queue, there is no guarantee that items will be delivered on claim in the order they were sent. For example, some implementations like beanstalkd or others with distributed back-ends like Amazon SQS will be managing jobs for a large set of producers and consumers where a strict FIFO ordering will likely not be preserved.
The system also makes no guarantees about a task only being executed once: callers that have non-idempotent tasks either need to live with the possiblity of the task being invoked multiple times in cases where a claim lease expires, or need to implement their own transactions to make their tasks idempotent.
2009-05-06 10:37:28 +00:00
2014-12-04 12:31:10 +00:00
// Clean up the expirable key value database store.
if ( \Drupal :: service ( 'keyvalue.expirable.database' ) instanceof KeyValueDatabaseExpirableFactory ) {
\Drupal :: service ( 'keyvalue.expirable.database' ) -> garbageCollection ();
}
2016-02-17 00:52:18 +00:00
// Clean up any garbage in the queue service.
2016-07-13 11:42:04 +00:00
$queue_worker_manager = \Drupal :: service ( 'plugin.manager.queue_worker' );
$queue_factory = \Drupal :: service ( 'queue' );
foreach ( array_keys ( $queue_worker_manager -> getDefinitions ()) as $queue_name ) {
$queue = $queue_factory -> get ( $queue_name );
if ( $queue instanceof QueueGarbageCollectionInterface ) {
$queue -> garbageCollection ();
}
2016-02-17 00:52:18 +00:00
}
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
// Ensure that all of Drupal's standard directories (e.g., the public files
// directory and config directory) have appropriate .htaccess files.
\Drupal :: service ( 'file.htaccess_writer' ) -> ensure ();
Issue #3041885 by tedbow, beautifulmind, dww, ayushmishra206, phenaproxima, webchick, xjm, AaronMcHale, larowlan, benjifisher, heddn, catch, jhodgdon, longwave, mglaman, alexpott, mxr576, effulgentsia: Display relevant Security Advisories data for Drupal
2021-05-12 06:40:17 +00:00
if ( \Drupal :: config ( 'system.advisories' ) -> get ( 'enabled' )) {
// Fetch the security advisories so that they will be pre-fetched during
// _system_advisories_requirements() and system_page_top().
/** @var \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher $fetcher */
$fetcher = \Drupal :: service ( 'system.sa_fetcher' );
$fetcher -> getSecurityAdvisories ();
}
2007-04-10 10:10:27 +00:00
}
2007-09-10 09:28:28 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_mail () .
2007-09-10 09:28:28 +00:00
*/
function system_mail ( $key , & $message , $params ) {
2013-09-16 03:58:06 +00:00
$token_service = \Drupal :: token ();
2013-04-18 07:24:35 +00:00
2007-09-10 09:28:28 +00:00
$context = $params [ 'context' ];
Issue #2567257 by dawehner, stefan.r, effulgentsia, pwolanin, catch, Xano, mr.baileys, Wim Leers, k4v, Dave Reid, chx, googletorp, plach, lauriii, Berdir, webchick, alexpott, stefan.r: hook_tokens() $sanitize option incompatible with Html sanitisation requirements
2015-10-01 13:01:21 +00:00
$subject = PlainTextOutput :: renderFromHtml ( $token_service -> replace ( $context [ 'subject' ], $context ));
2013-04-18 07:24:35 +00:00
$body = $token_service -> replace ( $context [ 'message' ], $context );
2009-08-19 20:19:37 +00:00
2017-03-04 01:20:24 +00:00
$message [ 'subject' ] .= str_replace ([ " \r " , " \n " ], '' , $subject );
2009-10-16 03:01:55 +00:00
$message [ 'body' ][] = $body ;
2007-09-10 09:28:28 +00:00
}
2007-12-16 21:01:45 +00:00
/**
* Generate an array of time zones and their local time & date .
2008-11-20 06:56:17 +00:00
*
Issue #2847651 by murrow, rachel_norfolk, john@johncook.me.uk, mpdonadio, BarisW, droplet, tstoeckler, andrewmacpherson, prabhu9484, ok_lyndsey, benjifisher, yoroy, lauriii, martin107: Improve timezones selector with optgroups
2017-07-22 05:06:54 +00:00
* @ param mixed $blank
2008-11-20 06:56:17 +00:00
* If evaluates true , prepend an empty time zone option to the array .
Issue #2847651 by murrow, rachel_norfolk, john@johncook.me.uk, mpdonadio, BarisW, droplet, tstoeckler, andrewmacpherson, prabhu9484, ok_lyndsey, benjifisher, yoroy, lauriii, martin107: Improve timezones selector with optgroups
2017-07-22 05:06:54 +00:00
* @ param bool $grouped
* ( optional ) Whether the timezones should be grouped by region .
*
* @ return array
* An array or nested array containing time zones , keyed by the system name .
2023-02-22 15:28:49 +00:00
*
* @ deprecated in drupal : 10.1 . 0 and is removed from drupal : 11.0 . 0. This function
* is no longer used in Drupal core . Use
* \Drupal\Core\Datetime\TimeZoneFormHelper :: getOptionsList () or
* \DateTimeZone :: listIdentifiers () instead .
*
* @ see https :// www . drupal . org / node / 3023528
2008-11-20 06:56:17 +00:00
*/
Issue #2847651 by murrow, rachel_norfolk, john@johncook.me.uk, mpdonadio, BarisW, droplet, tstoeckler, andrewmacpherson, prabhu9484, ok_lyndsey, benjifisher, yoroy, lauriii, martin107: Improve timezones selector with optgroups
2017-07-22 05:06:54 +00:00
function system_time_zones ( $blank = NULL , $grouped = FALSE ) {
2023-03-30 20:53:52 +00:00
@ trigger_error ( __METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. This function is no longer used in Drupal core. Use \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(), \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion() or \DateTimeZone::listIdentifiers() instead. See https://www.drupal.org/node/3023528' , E_USER_DEPRECATED );
return $grouped ? TimeZoneFormHelper :: getOptionsListByRegion (( bool ) $blank ) : TimeZoneFormHelper :: getOptionsList (( bool ) $blank );
2007-08-26 16:41:02 +00:00
}
2007-10-17 15:24:56 +00:00
2009-06-23 12:11:19 +00:00
/**
2013-04-09 20:27:45 +00:00
* Attempts to get a file using Guzzle HTTP client and to store it locally .
2009-06-23 12:11:19 +00:00
*
2014-02-13 00:19:44 +00:00
* @ param string $url
2009-06-23 12:11:19 +00:00
* The URL of the file to grab .
2014-02-13 00:19:44 +00:00
* @ param string $destination
2010-02-26 21:19:09 +00:00
* Stream wrapper URI specifying where the file should be placed . If a
* directory path is provided , the file is saved into that directory under
* its original name . If the path contains a filename as well , that one will
* be used instead .
* If this value is omitted , the site ' s default files scheme will be used ,
* usually " public:// " .
2014-02-13 00:19:44 +00:00
* @ param bool $managed
2010-02-26 21:19:09 +00:00
* If this is set to TRUE , the file API hooks will be invoked and the file is
* registered in the database .
2014-02-13 00:19:44 +00:00
* @ param int $replace
2010-02-26 21:19:09 +00:00
* Replace behavior when the destination file already exists :
2019-10-08 20:49:15 +00:00
* - FileSystemInterface :: EXISTS_REPLACE : Replace the existing file .
* - FileSystemInterface :: EXISTS_RENAME : Append _ { incrementing number } until
* the filename is unique .
* - FileSystemInterface :: EXISTS_ERROR : Do nothing and return FALSE .
2009-07-04 14:29:34 +00:00
*
2014-02-13 00:19:44 +00:00
* @ return mixed
* One of these possibilities :
* - If it succeeds and $managed is FALSE , the location where the file was
* saved .
* - If it succeeds and $managed is TRUE , a \Drupal\file\FileInterface
* object which describes the file .
* - If it fails , FALSE .
2023-06-23 00:28:41 +00:00
*
* @ deprecated in drupal : 10.2 . 0 and is removed from drupal : 11.0 . 0. There is no
* replacement .
*
* @ see https :// www . drupal . org / node / 3223362
2009-06-23 12:11:19 +00:00
*/
Issue #2244513 by kim.pepper, phenaproxima, 20th, andrei.dincu, beejeebus, Berdir, alexpott, jibran, andypost, larowlan, Chadwick Wood, acbramley, Wim Leers, sun, xjm, YesCT, chx, tim.plunkett: Move the unmanaged file APIs to the file_system service (file.inc)
2019-02-23 22:35:15 +00:00
function system_retrieve_file ( $url , $destination = NULL , $managed = FALSE , $replace = FileSystemInterface :: EXISTS_RENAME ) {
2023-06-23 00:28:41 +00:00
@ trigger_error ( 'system_retrieve_file is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3223362' , E_USER_DEPRECATED );
2009-07-01 13:44:53 +00:00
$parsed_url = parse_url ( $url );
Issue #2244513 by kim.pepper, phenaproxima, 20th, andrei.dincu, beejeebus, Berdir, alexpott, jibran, andypost, larowlan, Chadwick Wood, acbramley, Wim Leers, sun, xjm, YesCT, chx, tim.plunkett: Move the unmanaged file APIs to the file_system service (file.inc)
2019-02-23 22:35:15 +00:00
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal :: service ( 'file_system' );
2010-02-26 21:19:09 +00:00
if ( ! isset ( $destination )) {
2021-07-16 07:43:01 +00:00
$path = $file_system -> basename ( $parsed_url [ 'path' ]);
$path = \Drupal :: config ( 'system.file' ) -> get ( 'default_scheme' ) . '://' . $path ;
$path = \Drupal :: service ( 'stream_wrapper_manager' ) -> normalizeUri ( $path );
2010-02-26 21:19:09 +00:00
}
else {
Issue #2244513 by kim.pepper, phenaproxima, 20th, andrei.dincu, beejeebus, Berdir, alexpott, jibran, andypost, larowlan, Chadwick Wood, acbramley, Wim Leers, sun, xjm, YesCT, chx, tim.plunkett: Move the unmanaged file APIs to the file_system service (file.inc)
2019-02-23 22:35:15 +00:00
if ( is_dir ( $file_system -> realpath ( $destination ))) {
2010-02-26 21:19:09 +00:00
// Prevent URIs with triple slashes when glueing parts together.
2019-03-07 09:12:01 +00:00
$path = str_replace ( '///' , '//' , " $destination / " ) . \Drupal :: service ( 'file_system' ) -> basename ( $parsed_url [ 'path' ]);
2010-02-26 21:19:09 +00:00
}
else {
$path = $destination ;
}
2009-07-01 13:44:53 +00:00
}
2013-04-09 20:27:45 +00:00
try {
2015-07-24 23:16:20 +00:00
$data = ( string ) \Drupal :: httpClient ()
2013-04-09 20:27:45 +00:00
-> get ( $url )
2015-07-24 23:16:20 +00:00
-> getBody ();
Issue #3223209 by kim.pepper, dww, yogeshmpawar, daffie, larowlan, Berdir, andypost, phenaproxima, brianV, alexpott, AjitS, ravi.shankar, catch, quietone, trobey, Dave Reid, JacobSingh, imclean, tim.plunkett, Kars-T, amateescu, JeremyFrench, aaron: deprecate file_save_data, file_copy and file_move and replace with a service
2021-10-25 01:01:32 +00:00
if ( $managed ) {
/** @var \Drupal\file\FileRepositoryInterface $file_repository */
$file_repository = \Drupal :: service ( 'file.repository' );
$local = $file_repository -> writeData ( $data , $path , $replace );
}
else {
$local = $file_system -> saveData ( $data , $path , $replace );
}
2013-04-09 20:27:45 +00:00
}
2020-12-21 06:26:56 +00:00
catch ( TransferException $exception ) {
2018-05-01 09:15:07 +00:00
\Drupal :: messenger () -> addError ( t ( 'Failed to fetch file due to error "%error"' , [ '%error' => $exception -> getMessage ()]));
2009-07-01 13:44:53 +00:00
return FALSE ;
2009-06-23 12:11:19 +00:00
}
Issue #3223209 by kim.pepper, dww, yogeshmpawar, daffie, larowlan, Berdir, andypost, phenaproxima, brianV, alexpott, AjitS, ravi.shankar, catch, quietone, trobey, Dave Reid, JacobSingh, imclean, tim.plunkett, Kars-T, amateescu, JeremyFrench, aaron: deprecate file_save_data, file_copy and file_move and replace with a service
2021-10-25 01:01:32 +00:00
catch ( FileException | InvalidStreamWrapperException $e ) {
Issue #2244513 by kim.pepper, phenaproxima, 20th, andrei.dincu, beejeebus, Berdir, alexpott, jibran, andypost, larowlan, Chadwick Wood, acbramley, Wim Leers, sun, xjm, YesCT, chx, tim.plunkett: Move the unmanaged file APIs to the file_system service (file.inc)
2019-02-23 22:35:15 +00:00
\Drupal :: messenger () -> addError ( t ( 'Failed to save file due to error "%error"' , [ '%error' => $e -> getMessage ()]));
return FALSE ;
}
2010-02-26 21:19:09 +00:00
if ( ! $local ) {
2018-05-01 09:15:07 +00:00
\Drupal :: messenger () -> addError ( t ( '@remote could not be saved to @path.' , [ '@remote' => $url , '@path' => $path ]));
2010-02-26 21:19:09 +00:00
}
2009-08-24 00:14:23 +00:00
2009-06-23 12:11:19 +00:00
return $local ;
}
2009-08-22 16:01:10 +00:00
2014-08-29 04:42:51 +00:00
/**
* Implements hook_entity_type_build () .
*/
function system_entity_type_build ( array & $entity_types ) {
2021-05-20 20:47:18 +00:00
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
2014-08-29 04:42:51 +00:00
$entity_types [ 'date_format' ]
-> setFormClass ( 'add' , 'Drupal\system\Form\DateFormatAddForm' )
-> setFormClass ( 'edit' , 'Drupal\system\Form\DateFormatEditForm' )
-> setFormClass ( 'delete' , 'Drupal\system\Form\DateFormatDeleteForm' )
-> setListBuilderClass ( 'Drupal\system\DateFormatListBuilder' )
2015-01-13 10:32:23 +00:00
-> setLinkTemplate ( 'edit-form' , '/admin/config/regional/date-time/formats/manage/{date_format}' )
2015-01-19 09:37:11 +00:00
-> setLinkTemplate ( 'delete-form' , '/admin/config/regional/date-time/formats/manage/{date_format}/delete' )
-> setLinkTemplate ( 'collection' , '/admin/config/regional/date-time/formats' );
2014-08-29 04:42:51 +00:00
}
2014-02-05 13:22:50 +00:00
/**
* Implements hook_block_view_BASE_BLOCK_ID_alter () .
*/
function system_block_view_system_main_block_alter ( array & $build , BlockPluginInterface $block ) {
// Contextual links on the system_main block would basically duplicate the
// tabs/local tasks, so reduce the clutter.
unset ( $build [ '#contextual_links' ]);
}
2015-10-06 11:02:22 +00:00
/**
* Implements hook_query_TAG_alter () for entity reference selection handlers .
*/
function system_query_entity_reference_alter ( AlterableInterface $query ) {
$handler = $query -> getMetadata ( 'entity_reference_selection_handler' );
$handler -> entityQueryAlter ( $query );
}
2017-10-24 22:46:32 +00:00
/**
* Implements hook_element_info_alter () .
*/
function system_element_info_alter ( & $type ) {
if ( isset ( $type [ 'page' ])) {
$type [ 'page' ][ '#theme_wrappers' ][ 'off_canvas_page_wrapper' ] = [ '#weight' => - 1000 ];
}
}
2019-09-20 10:17:19 +00:00
/**
* Implements hook_modules_uninstalled () .
*/
function system_modules_uninstalled ( $modules ) {
// @todo Remove this when modules are able to maintain their revision metadata
// keys.
// @see https://www.drupal.org/project/drupal/issues/3074333
if ( ! in_array ( 'workspaces' , $modules , TRUE )) {
return ;
}
$entity_definition_update_manager = \Drupal :: entityDefinitionUpdateManager ();
foreach ( $entity_definition_update_manager -> getEntityTypes () as $entity_type ) {
2020-02-24 13:25:58 +00:00
if ( $entity_type instanceof ContentEntityTypeInterface && $entity_type -> hasRevisionMetadataKey ( 'workspace' )) {
$entity_type -> setRevisionMetadataKey ( 'workspace' , NULL );
2019-09-20 10:17:19 +00:00
$entity_definition_update_manager -> updateEntityType ( $entity_type );
}
}
}
2020-10-20 01:56:40 +00:00
/**
* Determines if Claro is the admin theme but not the active theme .
*
* @ return bool
* TRUE if Claro is the admin theme but not the active theme .
*/
function _system_is_claro_admin_and_not_active () {
$admin_theme = \Drupal :: configFactory () -> get ( 'system.theme' ) -> get ( 'admin' );
$active_theme = \Drupal :: theme () -> getActiveTheme () -> getName ();
return $active_theme !== 'claro' && $admin_theme === 'claro' ;
}
/**
* Implements hook_library_info_alter () .
*/
function system_library_info_alter ( & $libraries , $extension ) {
// If Claro is the admin theme but not the active theme, grant Claro the
// ability to override the toolbar library with its own assets.
if ( $extension === 'toolbar' && _system_is_claro_admin_and_not_active ()) {
require_once DRUPAL_ROOT . '/core/themes/claro/claro.theme' ;
claro_system_module_invoked_library_info_alter ( $libraries , $extension );
}
}
/**
* Implements hook_preprocess_toolbar () .
*/
function system_preprocess_toolbar ( array & $variables , $hook , $info ) {
// When Claro is the admin theme, Claro overrides the active theme's if that
// active theme is not Claro. Because of these potential overrides, the
// toolbar cache should be invalidated any time the default or admin theme
// changes.
$variables [ '#cache' ][ 'tags' ][] = 'config:system.theme' ;
// If Claro is the admin theme but not the active theme, still include Claro's
// toolbar preprocessing.
if ( _system_is_claro_admin_and_not_active ()) {
require_once DRUPAL_ROOT . '/core/themes/claro/claro.theme' ;
claro_preprocess_toolbar ( $variables , $hook , $info );
}
}
/**
* Implements hook_theme_registry_alter () .
*/
function system_theme_registry_alter ( array & $theme_registry ) {
// If Claro is the admin theme but not the active theme, use Claro's toolbar
// templates.
if ( _system_is_claro_admin_and_not_active ()) {
require_once DRUPAL_ROOT . '/core/themes/claro/claro.theme' ;
claro_system_module_invoked_theme_registry_alter ( $theme_registry );
}
}
Issue #3041885 by tedbow, beautifulmind, dww, ayushmishra206, phenaproxima, webchick, xjm, AaronMcHale, larowlan, benjifisher, heddn, catch, jhodgdon, longwave, mglaman, alexpott, mxr576, effulgentsia: Display relevant Security Advisories data for Drupal
2021-05-12 06:40:17 +00:00
/**
* Implements hook_page_top () .
*/
function system_page_top () {
/** @var \Drupal\Core\Routing\AdminContext $admin_context */
$admin_context = \Drupal :: service ( 'router.admin_context' );
if ( $admin_context -> isAdminRoute () && \Drupal :: currentUser () -> hasPermission ( 'administer site configuration' )) {
$route_match = \Drupal :: routeMatch ();
$route_name = $route_match -> getRouteName ();
if ( $route_name !== 'system.status' && \Drupal :: config ( 'system.advisories' ) -> get ( 'enabled' )) {
/** @var \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher $fetcher */
$fetcher = \Drupal :: service ( 'system.sa_fetcher' );
$advisories = $fetcher -> getSecurityAdvisories ( FALSE );
if ( $advisories ) {
$messenger = \Drupal :: messenger ();
$display_as_errors = FALSE ;
$links = [];
foreach ( $advisories as $advisory ) {
// To ensure that all the advisory messages are grouped together on
// the page, they must all be warnings or all be errors. If any
// advisories are not public service announcements, then display all
// the messages as errors because security advisories already tied to
// a specific release are immediately actionable by upgrading to a
// secure version of a project.
$display_as_errors = $display_as_errors ? TRUE : ! $advisory -> isPsa ();
$links [] = new Link ( $advisory -> getTitle (), Url :: fromUri ( $advisory -> getUrl ()));
}
foreach ( $links as $link ) {
$display_as_errors ? $messenger -> addError ( $link ) : $messenger -> addWarning ( $link );
}
if ( \Drupal :: moduleHandler () -> moduleExists ( 'help' )) {
$help_link = t ( '(<a href=":system-help">What are critical security announcements?</a>)' , [
':system-help' => Url :: fromRoute ( 'help.page' , [ 'name' => 'system' ], [ 'fragment' => 'security-advisories' ]) -> toString (),
]);
$display_as_errors ? $messenger -> addError ( $help_link ) : $messenger -> addWarning ( $help_link );
}
}
}
}
}
SA-CORE-2022-012 by cmlara, GuyPaddock, larowlan, mondrake, effulgentsia, xjm, longwave, Dave Reid, lauriii, David Strauss, benjifisher, alexpott, mcdruid, Fabianx
(cherry picked from commit 1f82337d1789424dcb1901eb68b820a7e141d8c5)
2022-07-20 15:11:30 +00:00
/**
* Implements hook_file_download () .
*/
function system_file_download ( $uri ) {
SA-CORE-2023-005 by benjifisher, Heine, cmlara, mlhess, larowlan, David_Rothstein, xjm, Wim Leers, DamienMcKenna, effulgentsia, pwolanin, mcdruid, poker10, jenlampton, longwave, kim.pepper, alexpott, drumm
2023-04-19 16:18:37 +00:00
$stream_wrapper_manager = \Drupal :: service ( 'stream_wrapper_manager' );
$scheme = $stream_wrapper_manager -> getScheme ( $uri );
if ( $stream_wrapper_manager -> isValidScheme ( $scheme )) {
$target = $stream_wrapper_manager -> getTarget ( $uri );
if ( $target !== FALSE ) {
if ( ! in_array ( $scheme , Settings :: get ( 'file_sa_core_2023_005_schemes' , []))) {
if ( DIRECTORY_SEPARATOR !== '/' ) {
$class = $stream_wrapper_manager -> getClass ( $scheme );
if ( is_subclass_of ( $class , LocalStream :: class )) {
$target = str_replace ( DIRECTORY_SEPARATOR , '/' , $target );
}
}
$parts = explode ( '/' , $target );
if ( array_intersect ( $parts , [ '.' , '..' ])) {
return - 1 ;
}
}
}
}
SA-CORE-2022-012 by cmlara, GuyPaddock, larowlan, mondrake, effulgentsia, xjm, longwave, Dave Reid, lauriii, David Strauss, benjifisher, alexpott, mcdruid, Fabianx
(cherry picked from commit 1f82337d1789424dcb1901eb68b820a7e141d8c5)
2022-07-20 15:11:30 +00:00
$core_schemes = [ 'public' , 'private' , 'temporary' ];
$additional_public_schemes = array_diff ( Settings :: get ( 'file_additional_public_schemes' , []), $core_schemes );
if ( $additional_public_schemes ) {
$scheme = StreamWrapperManager :: getScheme ( $uri );
if ( in_array ( $scheme , $additional_public_schemes , TRUE )) {
return [
// Returning any header grants access, and setting the 'Cache-Control'
// header is appropriate for public files.
'Cache-Control' => 'public' ,
];
}
}
}
2022-11-17 17:31:37 +00:00
/**
* Implements hook_archiver_info_alter () .
*/
function system_archiver_info_alter ( & $info ) {
if ( ! class_exists ( \ZipArchive :: class )) {
// PHP Zip extension is missing.
unset ( $info [ 'Zip' ]);
}
}
Issue #2921810 by claudiu.cristea, nod_, seanB, yogeshmpawar, dww, Wilfred Waltman, joelpittet, askibinski, ankithashetty, ravi.shankar, jonathanshaw, alexpott, kostyashupenko, webchick, danflanagan8, catch, droplet, larowlan, mpdonadio, jhedstrom, AaronMcHale, dawehner, Wim Leers, ckrina, worldlinemine: Allow TimestampFormatter to show as a fully cacheable time difference with JS
2023-03-03 16:35:58 +00:00
/**
* Implements hook_ENTITY_TYPE_presave () for entity_view_display entities .
*
* Provides a BC layer for modules providing old configurations .
*
* @ see https :// www . drupal . org / node / 2993639
*
* @ todo Remove this BC layer in drupal : 11.0 . 0.
*/
function system_entity_view_display_presave ( EntityViewDisplayInterface $entity_view_display ) : void {
/** @var \Drupal\Core\Field\FormatterPluginManager $field_formatter_manager */
$field_formatter_manager = \Drupal :: service ( 'plugin.manager.field.formatter' );
foreach ( $entity_view_display -> getComponents () as $name => $component ) {
if ( empty ( $component [ 'type' ])) {
continue ;
}
if ( ! $plugin_definition = $field_formatter_manager -> getDefinition ( $component [ 'type' ], FALSE )) {
continue ;
}
// Check also potential plugins that extends TimestampFormatter.
if ( ! is_a ( $plugin_definition [ 'class' ], TimestampFormatter :: class , TRUE )) {
continue ;
}
if ( ! isset ( $component [ 'settings' ][ 'tooltip' ]) || ! isset ( $component [ 'settings' ][ 'time_diff' ])) {
@ trigger_error ( " The 'timestamp' formatter plugin 'tooltip' and 'time_diff' settings were added in drupal:10.1.0 and will be mandatory in Drupal 11.0.0. See https://www.drupal.org/node/2993639 " , E_USER_DEPRECATED );
$entity_view_display -> setComponent ( $name , $component );
}
}
}