2007-07-11 15:15:40 +00:00
< ? php
/**
* @ file
* Code required only when rendering the available updates report .
*/
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
use Drupal\Core\Template\Attribute ;
2014-09-30 06:50:14 +00:00
use Drupal\Core\Url ;
2021-06-23 03:51:34 +00:00
use Drupal\update\ProjectRelease ;
2019-12-04 11:57:25 +00:00
use Drupal\update\UpdateFetcherInterface ;
use Drupal\update\UpdateManagerInterface ;
2014-06-13 02:33:48 +00:00
2007-07-11 15:15:40 +00:00
/**
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
* Prepares variables for project status report templates .
*
* Default template : update - report . html . twig .
2010-04-13 15:23:03 +00:00
*
2010-10-03 22:43:16 +00:00
* @ param array $variables
2010-04-13 15:23:03 +00:00
* An associative array containing :
* - data : An array of data about each project ' s status .
2007-07-11 15:15:40 +00:00
*/
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
function template_preprocess_update_report ( & $variables ) {
2020-05-28 08:52:41 +00:00
$data = isset ( $variables [ 'data' ]) && is_array ( $variables [ 'data' ]) ? $variables [ 'data' ] : [];
2009-10-09 01:00:08 +00:00
2020-05-02 12:07:36 +00:00
$last = \Drupal :: state () -> get ( 'update.last_check' , 0 );
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
2017-03-04 01:20:24 +00:00
$variables [ 'last_checked' ] = [
2013-08-13 10:53:04 +00:00
'#theme' => 'update_last_check' ,
'#last' => $last ,
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// Attach the library to a variable that gets printed always.
2017-03-04 01:20:24 +00:00
'#attached' => [
'library' => [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'update/drupal.update.admin' ,
2017-03-04 01:20:24 +00:00
],
2018-05-11 09:40:33 +00:00
],
2017-03-04 01:20:24 +00:00
];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// For no project update data, populate no data message.
if ( empty ( $data )) {
$variables [ 'no_updates_message' ] = _update_no_data ();
2007-07-11 15:15:40 +00:00
}
2017-03-04 01:20:24 +00:00
$rows = [];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
2007-07-11 15:15:40 +00:00
foreach ( $data as $project ) {
2017-03-04 01:20:24 +00:00
$project_status = [
2016-04-29 11:02:20 +00:00
'#theme' => 'update_project_status' ,
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#project' => $project ,
2017-03-04 01:20:24 +00:00
];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// Build project rows.
if ( ! isset ( $rows [ $project [ 'project_type' ]])) {
2017-03-04 01:20:24 +00:00
$rows [ $project [ 'project_type' ]] = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#type' => 'table' ,
2017-03-04 01:20:24 +00:00
'#attributes' => [ 'class' => [ 'update' ]],
];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
2018-05-08 16:23:11 +00:00
$row_key = ! empty ( $project [ 'title' ]) ? mb_strtolower ( $project [ 'title' ]) : mb_strtolower ( $project [ 'name' ]);
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// Add the project status row and details.
$rows [ $project [ 'project_type' ]][ $row_key ][ 'status' ] = $project_status ;
// Add project status class attribute to the table row.
2007-07-11 15:15:40 +00:00
switch ( $project [ 'status' ]) {
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: CURRENT :
2017-03-04 01:20:24 +00:00
$rows [ $project [ 'project_type' ]][ $row_key ][ '#attributes' ] = [ 'class' => [ 'color-success' ]];
2015-08-19 07:40:38 +00:00
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateFetcherInterface :: UNKNOWN :
case UpdateFetcherInterface :: FETCH_PENDING :
case UpdateFetcherInterface :: NOT_FETCHED :
case UpdateManagerInterface :: NOT_SECURE :
case UpdateManagerInterface :: REVOKED :
case UpdateManagerInterface :: NOT_SUPPORTED :
2017-03-04 01:20:24 +00:00
$rows [ $project [ 'project_type' ]][ $row_key ][ '#attributes' ] = [ 'class' => [ 'color-error' ]];
2009-04-29 03:57:21 +00:00
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateFetcherInterface :: NOT_CHECKED :
case UpdateManagerInterface :: NOT_CURRENT :
2007-07-11 15:15:40 +00:00
default :
2017-03-04 01:20:24 +00:00
$rows [ $project [ 'project_type' ]][ $row_key ][ '#attributes' ] = [ 'class' => [ 'color-warning' ]];
2007-07-11 15:15:40 +00:00
break ;
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
2007-07-11 15:15:40 +00:00
2017-03-04 01:20:24 +00:00
$project_types = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'core' => t ( 'Drupal core' ),
'module' => t ( 'Modules' ),
'theme' => t ( 'Themes' ),
2024-01-11 13:36:10 +00:00
'module-uninstalled' => t ( 'Uninstalled modules' ),
'theme-uninstalled' => t ( 'Uninstalled themes' ),
2017-03-04 01:20:24 +00:00
];
2013-08-13 10:53:04 +00:00
2017-03-04 01:20:24 +00:00
$variables [ 'project_types' ] = [];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
foreach ( $project_types as $type_name => $type_label ) {
if ( ! empty ( $rows [ $type_name ])) {
ksort ( $rows [ $type_name ]);
2017-03-04 01:20:24 +00:00
$variables [ 'project_types' ][] = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'label' => $type_label ,
'table' => $rows [ $type_name ],
2017-03-04 01:20:24 +00:00
];
2007-07-11 15:15:40 +00:00
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
}
2007-07-11 15:15:40 +00:00
Issue #3102724 by dww, tedbow, bnjmnm, webchick, ckrina, Gábor Hojtsy, xjm, benjifisher, AaronMcHale, lauriii, shaal, andrewmacpherson, rainbreaw, worldlinemine: Improve usability of core compatibility ranges on available updates report
2020-02-27 10:27:01 +00:00
/**
* Prepares variables for update version templates .
*
* Default template : update - version . html . twig .
*
* @ param array $variables
* An associative array containing :
* - version : An array of information about the release version .
*/
function template_preprocess_update_version ( array & $variables ) {
2021-06-23 03:51:34 +00:00
$release = ProjectRelease :: createFromArray ( $variables [ 'version' ]);
if ( ! $release -> getCoreCompatibilityMessage ()) {
Issue #3102724 by dww, tedbow, bnjmnm, webchick, ckrina, Gábor Hojtsy, xjm, benjifisher, AaronMcHale, lauriii, shaal, andrewmacpherson, rainbreaw, worldlinemine: Improve usability of core compatibility ranges on available updates report
2020-02-27 10:27:01 +00:00
return ;
}
2021-06-23 03:51:34 +00:00
$core_compatible = $release -> isCoreCompatible ();
Issue #3102724 by dww, tedbow, bnjmnm, webchick, ckrina, Gábor Hojtsy, xjm, benjifisher, AaronMcHale, lauriii, shaal, andrewmacpherson, rainbreaw, worldlinemine: Improve usability of core compatibility ranges on available updates report
2020-02-27 10:27:01 +00:00
$variables [ 'core_compatibility_details' ] = [
'#type' => 'details' ,
'#title' => $core_compatible ? t ( 'Compatible' ) : t ( 'Not compatible' ),
'#open' => ! $core_compatible ,
'message' => [
2021-06-23 03:51:34 +00:00
'#markup' => $release -> getCoreCompatibilityMessage (),
Issue #3102724 by dww, tedbow, bnjmnm, webchick, ckrina, Gábor Hojtsy, xjm, benjifisher, AaronMcHale, lauriii, shaal, andrewmacpherson, rainbreaw, worldlinemine: Improve usability of core compatibility ranges on available updates report
2020-02-27 10:27:01 +00:00
],
'#attributes' => [
'class' => [
$core_compatible ? 'compatible' : 'not-compatible' ,
],
],
];
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
/**
* Prepares variables for update project status templates .
*
* Default template : update - project - status . html . twig .
*
* @ param array $variables
* An associative array containing :
* - project : An array of information about the project .
*/
function template_preprocess_update_project_status ( & $variables ) {
// Storing by reference because we are sorting the project values.
$project = & $variables [ 'project' ];
// Set the project title and URL.
$variables [ 'title' ] = ( isset ( $project [ 'title' ])) ? $project [ 'title' ] : $project [ 'name' ];
2014-09-30 06:50:14 +00:00
$variables [ 'url' ] = ( isset ( $project [ 'link' ])) ? Url :: fromUri ( $project [ 'link' ]) -> toString () : NULL ;
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$variables [ 'install_type' ] = $project [ 'install_type' ];
if ( $project [ 'install_type' ] == 'dev' && ! empty ( $project [ 'datestamp' ])) {
2019-01-01 19:15:24 +00:00
$variables [ 'datestamp' ] = \Drupal :: service ( 'date.formatter' ) -> format ( $project [ 'datestamp' ], 'custom' , 'Y-M-d' );
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
2007-07-11 15:15:40 +00:00
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$variables [ 'existing_version' ] = $project [ 'existing_version' ];
2017-03-04 01:20:24 +00:00
$versions_inner = [];
$security_class = [];
$version_class = [];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
if ( isset ( $project [ 'recommended' ])) {
2019-12-04 11:57:25 +00:00
if ( $project [ 'status' ] != UpdateManagerInterface :: CURRENT || $project [ 'existing_version' ] !== $project [ 'recommended' ]) {
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// First, figure out what to recommend.
// If there's only 1 security update and it has the same version we're
// recommending, give it the same CSS class as if it was recommended,
// but don't print out a separate "Recommended" line for this project.
if ( ! empty ( $project [ 'security updates' ])
&& count ( $project [ 'security updates' ]) == 1
&& $project [ 'security updates' ][ 0 ][ 'version' ] === $project [ 'recommended' ]
) {
2015-04-18 10:39:39 +00:00
$security_class [] = 'project-update__version--recommended' ;
$security_class [] = 'project-update__version---strong' ;
2007-07-11 15:15:40 +00:00
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
else {
2015-04-18 10:39:39 +00:00
$version_class [] = 'project-update__version--recommended' ;
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// Apply an extra class if we're displaying both a recommended
// version and anything else for an extra visual hint.
if ( $project [ 'recommended' ] !== $project [ 'latest_version' ]
|| ! empty ( $project [ 'also' ])
|| ( $project [ 'install_type' ] == 'dev'
&& isset ( $project [ 'dev_version' ])
&& $project [ 'latest_version' ] !== $project [ 'dev_version' ]
&& $project [ 'recommended' ] !== $project [ 'dev_version' ])
|| ( isset ( $project [ 'security updates' ][ 0 ])
&& $project [ 'recommended' ] !== $project [ 'security updates' ][ 0 ])
) {
2015-04-18 10:39:39 +00:00
$version_class [] = 'project-update__version--recommended-strong' ;
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
2017-03-04 01:20:24 +00:00
$versions_inner [] = [
2013-08-13 10:53:04 +00:00
'#theme' => 'update_version' ,
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#version' => $project [ 'releases' ][ $project [ 'recommended' ]],
'#title' => t ( 'Recommended version:' ),
2017-03-04 01:20:24 +00:00
'#attributes' => [ 'class' => $version_class ],
];
2007-07-11 15:15:40 +00:00
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// Now, print any security updates.
if ( ! empty ( $project [ 'security updates' ])) {
$security_class [] = 'version-security' ;
foreach ( $project [ 'security updates' ] as $security_update ) {
2017-03-04 01:20:24 +00:00
$versions_inner [] = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#theme' => 'update_version' ,
'#version' => $security_update ,
'#title' => t ( 'Security update:' ),
2017-03-04 01:20:24 +00:00
'#attributes' => [ 'class' => $security_class ],
];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
2007-07-11 15:15:40 +00:00
}
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
if ( $project [ 'recommended' ] !== $project [ 'latest_version' ]) {
2017-03-04 01:20:24 +00:00
$versions_inner [] = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#theme' => 'update_version' ,
'#version' => $project [ 'releases' ][ $project [ 'latest_version' ]],
'#title' => t ( 'Latest version:' ),
2017-03-04 01:20:24 +00:00
'#attributes' => [ 'class' => [ 'version-latest' ]],
];
2010-10-03 22:43:16 +00:00
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
if ( $project [ 'install_type' ] == 'dev'
2019-12-04 11:57:25 +00:00
&& $project [ 'status' ] != UpdateManagerInterface :: CURRENT
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
&& isset ( $project [ 'dev_version' ])
&& $project [ 'recommended' ] !== $project [ 'dev_version' ]) {
2017-03-04 01:20:24 +00:00
$versions_inner [] = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#theme' => 'update_version' ,
'#version' => $project [ 'releases' ][ $project [ 'dev_version' ]],
'#title' => t ( 'Development version:' ),
2017-03-04 01:20:24 +00:00
'#attributes' => [ 'class' => [ 'version-latest' ]],
];
2007-07-11 15:15:40 +00:00
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
2007-07-11 15:15:40 +00:00
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
if ( isset ( $project [ 'also' ])) {
foreach ( $project [ 'also' ] as $also ) {
2017-03-04 01:20:24 +00:00
$versions_inner [] = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#theme' => 'update_version' ,
'#version' => $project [ 'releases' ][ $also ],
'#title' => t ( 'Also available:' ),
2017-03-04 01:20:24 +00:00
'#attributes' => [ 'class' => [ 'version-also-available' ]],
];
2009-10-08 15:40:34 +00:00
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
}
2009-10-08 15:40:34 +00:00
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
if ( ! empty ( $versions_inner )) {
$variables [ 'versions' ] = $versions_inner ;
}
2009-10-08 15:40:34 +00:00
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
if ( ! empty ( $project [ 'disabled' ])) {
sort ( $project [ 'disabled' ]);
$variables [ 'disabled' ] = $project [ 'disabled' ];
}
2007-07-11 15:15:40 +00:00
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
sort ( $project [ 'includes' ]);
$variables [ 'includes' ] = $project [ 'includes' ];
2017-03-04 01:20:24 +00:00
$variables [ 'extras' ] = [];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
if ( ! empty ( $project [ 'extra' ])) {
foreach ( $project [ 'extra' ] as $value ) {
2017-03-04 01:20:24 +00:00
$extra_item = [];
2014-09-27 07:42:04 +00:00
$extra_item [ 'attributes' ] = new Attribute ();
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$extra_item [ 'label' ] = $value [ 'label' ];
2015-08-21 15:01:46 +00:00
$extra_item [ 'data' ] = [
'#prefix' => '<em>' ,
'#markup' => $value [ 'data' ],
2018-05-11 09:40:33 +00:00
'#suffix' => '</em>' ,
2015-08-21 15:01:46 +00:00
];
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$variables [ 'extras' ][] = $extra_item ;
2007-07-11 15:15:40 +00:00
}
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
// Set the project status details.
$status_label = NULL ;
switch ( $project [ 'status' ]) {
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: NOT_SECURE :
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$status_label = t ( 'Security update required!' );
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: REVOKED :
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$status_label = t ( 'Revoked!' );
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: NOT_SUPPORTED :
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$status_label = t ( 'Not supported!' );
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: NOT_CURRENT :
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$status_label = t ( 'Update available' );
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: CURRENT :
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$status_label = t ( 'Up to date' );
break ;
}
$variables [ 'status' ][ 'label' ] = $status_label ;
2014-09-27 07:42:04 +00:00
$variables [ 'status' ][ 'attributes' ] = new Attribute ();
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$variables [ 'status' ][ 'reason' ] = ( isset ( $project [ 'reason' ])) ? $project [ 'reason' ] : NULL ;
2009-10-08 15:40:34 +00:00
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
switch ( $project [ 'status' ]) {
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: CURRENT :
2014-08-18 16:54:05 +00:00
$uri = 'core/misc/icons/73b355/check.svg' ;
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$text = t ( 'Ok' );
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateFetcherInterface :: UNKNOWN :
case UpdateFetcherInterface :: FETCH_PENDING :
case UpdateFetcherInterface :: NOT_FETCHED :
2014-08-18 16:54:05 +00:00
$uri = 'core/misc/icons/e29700/warning.svg' ;
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$text = t ( 'Warning' );
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateManagerInterface :: NOT_SECURE :
case UpdateManagerInterface :: REVOKED :
case UpdateManagerInterface :: NOT_SUPPORTED :
2015-09-02 12:21:25 +00:00
$uri = 'core/misc/icons/e32700/error.svg' ;
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$text = t ( 'Error' );
break ;
2020-06-02 08:46:52 +00:00
2019-12-04 11:57:25 +00:00
case UpdateFetcherInterface :: NOT_CHECKED :
case UpdateManagerInterface :: NOT_CURRENT :
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
default :
2014-08-18 16:54:05 +00:00
$uri = 'core/misc/icons/e29700/warning.svg' ;
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
$text = t ( 'Warning' );
break ;
2009-10-08 15:40:34 +00:00
}
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
2017-03-04 01:20:24 +00:00
$variables [ 'status' ][ 'icon' ] = [
Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
2014-07-31 13:03:12 +00:00
'#theme' => 'image' ,
'#width' => 18 ,
'#height' => 18 ,
'#uri' => $uri ,
'#alt' => $text ,
'#title' => $text ,
2017-03-04 01:20:24 +00:00
];
2009-10-08 15:40:34 +00:00
}
Issue #1538118 by dww, swentel, dawehner, pwolanin, sanduhrs, alexpott, ayushmishra206, Wim Leers, yogeshmpawar, mgifford, cilefen, David_Rothstein, drumm, larowlan, Heine, colan, tedbow, benjifisher, klausi, borisson_, quietone: Update status does not verify the identity or authenticity of the release history URL
2020-11-04 22:53:31 +00:00
/**
* Prepares variables for update fetch error message templates .
*
* Default template : update - fetch - error - message . html . twig .
*
* @ param array $variables
* An associative array of template variables .
*/
function template_preprocess_update_fetch_error_message ( & $variables ) : void {
$variables [ 'error_message' ] = [
'message' => [
'#markup' => t ( 'Failed to fetch available update data:' ),
],
'items' => [
'#theme' => 'item_list' ,
'#items' => [
'documentation_link' => t ( 'See <a href="@url">PHP OpenSSL requirements</a> in the Drupal.org handbook for possible reasons this could happen and what you can do to resolve them.' , [ '@url' => 'https://www.drupal.org/node/3170647' ]),
],
],
];
if ( \Drupal :: moduleHandler () -> moduleExists ( 'dblog' ) && \Drupal :: currentUser () -> hasPermission ( 'access site reports' )) {
$options = [ 'query' => [ 'type' => [ 'update' ]]];
$dblog_url = Url :: fromRoute ( 'dblog.overview' , [], $options );
$variables [ 'error_message' ][ 'items' ][ '#items' ][ 'dblog' ] = t ( 'Check <a href="@url">your local system logs</a> for additional error messages.' , [ '@url' => $dblog_url -> toString ()]);
}
else {
$variables [ 'error_message' ][ 'items' ][ '#items' ][ 'logs' ] = t ( 'Check your local system logs for additional error messages.' );
}
}