2007-05-22 05:52:17 +00:00
< ? php
/**
2007-08-26 16:41:02 +00:00
* @ file
* Admin page callbacks for the system module .
*/
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
use Symfony\Component\HttpFoundation\RedirectResponse ;
2012-06-04 12:06:09 +00:00
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException ;
2012-04-13 05:01:33 +00:00
2009-12-01 00:39:35 +00:00
/**
* Menu callback ; Set the default theme .
*/
function system_theme_default () {
2013-09-16 03:58:06 +00:00
$request = \Drupal :: request ();
2013-07-10 12:00:03 +00:00
$theme = $request -> get ( 'theme' );
2013-12-04 04:27:53 +00:00
if ( ! empty ( $theme )) {
2009-12-01 00:39:35 +00:00
// Get current list of themes.
2010-04-28 19:34:46 +00:00
$themes = list_themes ();
2009-12-01 00:39:35 +00:00
// Check if the specified theme is one recognized by the system.
if ( ! empty ( $themes [ $theme ])) {
// Enable the theme if it is currently disabled.
if ( empty ( $themes [ $theme ] -> status )) {
theme_enable ( array ( $theme ));
}
// Set the default theme.
2013-09-16 03:58:06 +00:00
\Drupal :: config ( 'system.theme' )
2013-03-04 14:04:05 +00:00
-> set ( 'default' , $theme )
-> save ();
2011-05-13 19:32:13 +00:00
2012-05-03 15:09:39 +00:00
// Rebuild the menu. This duplicates the menu_router_rebuild() in
// theme_enable(). However, modules must know the current default theme in
// order to use this information in hook_menu() or hook_menu_alter()
// implementations, and doing the variable_set() before the theme_enable()
// could result in a race condition where the theme is default but not
// enabled.
2013-10-24 12:04:38 +00:00
\Drupal :: service ( 'router.builder' ) -> rebuild ();
2012-05-03 15:09:39 +00:00
menu_router_rebuild ();
2013-10-24 12:04:38 +00:00
\Drupal :: cache ( 'cache' ) -> deleteTags ( array ( 'local_task' => 1 ));
2011-05-13 19:32:13 +00:00
2010-02-15 15:07:57 +00:00
// The status message depends on whether an admin theme is currently in use:
// a value of 0 means the admin theme is set to be the default theme.
2013-09-16 03:58:06 +00:00
$admin_theme = \Drupal :: config ( 'system.theme' ) -> get ( 'admin' );
2010-02-15 15:07:57 +00:00
if ( $admin_theme != 0 && $admin_theme != $theme ) {
2009-12-01 00:39:35 +00:00
drupal_set_message ( t ( 'Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.' , array (
'%admin_theme' => $themes [ $admin_theme ] -> info [ 'name' ],
'%selected_theme' => $themes [ $theme ] -> info [ 'name' ],
)));
}
else {
drupal_set_message ( t ( '%theme is now the default theme.' , array ( '%theme' => $themes [ $theme ] -> info [ 'name' ])));
}
}
else {
drupal_set_message ( t ( 'The %theme theme was not found.' , array ( '%theme' => $theme )), 'error' );
}
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 new RedirectResponse ( url ( 'admin/appearance' , array ( 'absolute' => TRUE )));
2009-12-01 00:39:35 +00:00
}
2012-06-04 12:06:09 +00:00
throw new AccessDeniedHttpException ();
2007-08-26 16:41:02 +00:00
}
2007-09-14 12:16:55 +00:00
/**
2007-12-16 21:01:45 +00:00
* Recursively check compatibility .
*
* @ param $incompatible
2009-01-14 12:18:37 +00:00
* An associative array which at the end of the check contains all
* incompatible files as the keys , their values being TRUE .
2007-12-16 21:01:45 +00:00
* @ param $files
* The set of files that will be tested .
* @ param $file
* The file at which the check starts .
* @ return
2009-01-14 12:18:37 +00:00
* Returns TRUE if an incompatible file is found , NULL ( no return value )
* otherwise .
2007-09-14 12:16:55 +00:00
*/
function _system_is_incompatible ( & $incompatible , $files , $file ) {
if ( isset ( $incompatible [ $file -> name ])) {
return TRUE ;
}
2009-01-14 12:18:37 +00:00
// Recursively traverse required modules, looking for incompatible modules.
foreach ( $file -> requires as $requires ) {
if ( isset ( $files [ $requires ]) && _system_is_incompatible ( $incompatible , $files , $files [ $requires ])) {
2007-09-14 12:16:55 +00:00
$incompatible [ $file -> name ] = TRUE ;
return TRUE ;
}
}
}
2007-08-26 16:41:02 +00:00
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for an administrative block for display .
2007-08-26 16:41:02 +00:00
*
2009-10-09 01:00:08 +00:00
* @ param $variables
* An associative array containing :
2010-10-01 15:24:18 +00:00
* - block : An array containing information about the block :
* - show : A Boolean whether to output the block . Defaults to FALSE .
* - title : The block ' s title .
* - content : ( optional ) Formatted content for the block .
* - description : ( optional ) Description of the block . Only output if
* 'content' is not set .
2009-10-09 01:00:08 +00:00
*
2007-12-06 09:58:34 +00:00
* @ ingroup themeable
2007-08-26 16:41:02 +00:00
*/
2009-10-09 01:00:08 +00:00
function theme_admin_block ( $variables ) {
$block = $variables [ 'block' ];
2010-10-01 15:24:18 +00:00
$output = '' ;
2009-10-09 01:00:08 +00:00
2007-08-26 16:41:02 +00:00
// Don't display the block if it has no content to display.
2009-08-25 10:37:36 +00:00
if ( empty ( $block [ 'show' ])) {
2010-10-01 15:24:18 +00:00
return $output ;
2007-08-26 16:41:02 +00:00
}
2010-10-01 15:24:18 +00:00
$output .= '<div class="admin-panel">' ;
if ( ! empty ( $block [ 'title' ])) {
$output .= '<h3>' . $block [ 'title' ] . '</h3>' ;
}
if ( ! empty ( $block [ 'content' ])) {
2013-08-28 06:44:11 +00:00
$output .= '<div class="body">' . render ( $block [ 'content' ]) . '</div>' ;
2009-08-21 07:59:47 +00:00
}
else {
2010-10-01 15:24:18 +00:00
$output .= '<div class="description">' . $block [ 'description' ] . '</div>' ;
2009-08-21 07:59:47 +00:00
}
2010-10-01 15:24:18 +00:00
$output .= '</div>' ;
2007-08-26 16:41:02 +00:00
return $output ;
}
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for the content of an administrative block .
2007-08-26 16:41:02 +00:00
*
2009-10-09 01:00:08 +00:00
* @ param $variables
* An associative array containing :
2010-10-01 15:24:18 +00:00
* - content : An array containing information about the block . Each element
* of the array represents an administrative menu item , and must at least
* contain the keys 'title' , 'href' , and 'localized_options' , which are
* passed to l () . A 'description' key may also be provided .
2009-10-09 01:00:08 +00:00
*
2007-12-06 09:58:34 +00:00
* @ ingroup themeable
2007-08-26 16:41:02 +00:00
*/
2009-10-09 01:00:08 +00:00
function theme_admin_block_content ( $variables ) {
$content = $variables [ 'content' ];
2010-10-01 15:24:18 +00:00
$output = '' ;
2009-10-09 01:00:08 +00:00
2010-10-01 15:24:18 +00:00
if ( ! empty ( $content )) {
$class = 'admin-list' ;
if ( $compact = system_admin_compact_mode ()) {
$class .= ' compact' ;
2007-08-26 16:41:02 +00:00
}
2010-10-01 15:24:18 +00:00
$output .= '<dl class="' . $class . '">' ;
2007-08-26 16:41:02 +00:00
foreach ( $content as $item ) {
2008-04-14 17:48:46 +00:00
$output .= '<dt>' . l ( $item [ 'title' ], $item [ 'href' ], $item [ 'localized_options' ]) . '</dt>' ;
2010-10-01 15:24:18 +00:00
if ( ! $compact && isset ( $item [ 'description' ])) {
$output .= '<dd>' . filter_xss_admin ( $item [ 'description' ]) . '</dd>' ;
}
2007-08-26 16:41:02 +00:00
}
$output .= '</dl>' ;
}
return $output ;
}
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for an administrative page .
2007-08-26 16:41:02 +00:00
*
2009-10-09 01:00:08 +00:00
* @ param $variables
* An associative array containing :
* - blocks : An array of blocks to display . Each array should include a
2010-04-13 15:23:03 +00:00
* 'title' , a 'description' , a formatted 'content' and a 'position' which
* will control which container it will be in . This is usually 'left' or
* 'right' .
2009-10-09 01:00:08 +00:00
*
2007-12-06 09:58:34 +00:00
* @ ingroup themeable
2007-08-26 16:41:02 +00:00
*/
2009-10-09 01:00:08 +00:00
function theme_admin_page ( $variables ) {
$blocks = $variables [ 'blocks' ];
2007-08-26 16:41:02 +00:00
$stripe = 0 ;
$container = array ();
foreach ( $blocks as $block ) {
2013-09-25 07:49:11 +00:00
$admin_block = array (
'#theme' => 'admin_block' ,
'#block' => $block ,
);
if ( $block_output = drupal_render ( $admin_block )) {
2007-08-26 16:41:02 +00:00
if ( empty ( $block [ 'position' ])) {
// perform automatic striping.
$block [ 'position' ] = ++ $stripe % 2 ? 'left' : 'right' ;
}
if ( ! isset ( $container [ $block [ 'position' ]])) {
$container [ $block [ 'position' ]] = '' ;
}
$container [ $block [ 'position' ]] .= $block_output ;
}
}
2013-09-25 07:49:11 +00:00
$system_compact_link = array ( '#theme' => 'system_compact_link' );
2009-02-18 14:28:25 +00:00
$output = '<div class="admin clearfix">' ;
2013-09-25 07:49:11 +00:00
$output .= drupal_render ( $system_compact_link );
2007-08-26 16:41:02 +00:00
foreach ( $container as $id => $data ) {
2009-02-18 14:28:25 +00:00
$output .= '<div class="' . $id . ' clearfix">' ;
2007-08-26 16:41:02 +00:00
$output .= $data ;
$output .= '</div>' ;
}
$output .= '</div>' ;
return $output ;
}
/**
2012-07-22 04:23:27 +00:00
* Returns HTML for the output of the admin index page .
2007-12-06 09:58:34 +00:00
*
2009-10-09 01:00:08 +00:00
* @ param $variables
* An associative array containing :
* - menu_items : An array of modules to be displayed .
*
2007-12-06 09:58:34 +00:00
* @ ingroup themeable
2007-08-26 16:41:02 +00:00
*/
2010-10-01 15:24:18 +00:00
function theme_system_admin_index ( $variables ) {
2009-10-09 01:00:08 +00:00
$menu_items = $variables [ 'menu_items' ];
2007-08-26 16:41:02 +00:00
$container = array ( 'left' => '' , 'right' => '' );
$flip = array ( 'left' => 'right' , 'right' => 'left' );
$position = 'left' ;
2010-04-22 09:54:26 +00:00
// Iterate over all modules.
2007-08-26 16:41:02 +00:00
foreach ( $menu_items as $module => $block ) {
list ( $description , $items ) = $block ;
2010-04-22 09:54:26 +00:00
// Output links.
2007-08-26 16:41:02 +00:00
if ( count ( $items )) {
2013-09-25 07:49:11 +00:00
$admin_block_content = array (
'#theme' => 'admin_block_content' ,
'#content' => $items ,
);
2007-08-26 16:41:02 +00:00
$block = array ();
$block [ 'title' ] = $module ;
2013-09-25 07:49:11 +00:00
$block [ 'content' ] = drupal_render ( $admin_block_content );
2007-08-26 16:41:02 +00:00
$block [ 'description' ] = t ( $description );
2009-08-25 10:37:36 +00:00
$block [ 'show' ] = TRUE ;
2007-08-26 16:41:02 +00:00
2013-09-25 07:49:11 +00:00
$admin_block = array (
'#theme' => 'admin_block' ,
'#block' => $block ,
);
if ( $block_output = drupal_render ( $admin_block )) {
2007-08-26 16:41:02 +00:00
if ( ! isset ( $block [ 'position' ])) {
// Perform automatic striping.
$block [ 'position' ] = $position ;
$position = $flip [ $position ];
}
$container [ $block [ 'position' ]] .= $block_output ;
}
}
}
2013-09-25 07:49:11 +00:00
$system_compact_link = array ( '#theme' => 'system_compact_link' );
2009-02-18 14:28:25 +00:00
$output = '<div class="admin clearfix">' ;
2013-09-25 07:49:11 +00:00
$output .= drupal_render ( $system_compact_link );
2007-08-26 16:41:02 +00:00
foreach ( $container as $id => $data ) {
2009-02-18 14:28:25 +00:00
$output .= '<div class="' . $id . ' clearfix">' ;
2007-08-26 16:41:02 +00:00
$output .= $data ;
$output .= '</div>' ;
}
$output .= '</div>' ;
return $output ;
}
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for the status report .
2007-08-30 15:31:46 +00:00
*
2013-10-31 12:42:26 +00:00
* This theme function is dependent on install . inc being loaded , because
* that ' s where the constants are defined .
*
2009-10-09 01:00:08 +00:00
* @ param $variables
* An associative array containing :
2013-10-31 12:42:26 +00:00
* - requirements : An array of requirements / status items . Each requirement
* is an associative array containing the following elements :
* - title : The name of the requirement .
* - value : ( optional ) The current value ( version , time , level , etc ) .
* - description : ( optional ) The description of the requirement .
* - severity : ( optional ) The requirement ' s result / severity level , one of :
* - REQUIREMENT_INFO : Status information .
* - REQUIREMENT_OK : The requirement is satisfied .
* - REQUIREMENT_WARNING : The requirement failed with a warning .
* - REQUIREMENT_ERROR : The requirement failed with an error .
2009-10-09 01:00:08 +00:00
*
2007-08-26 16:41:02 +00:00
* @ ingroup themeable
*/
2009-10-09 01:00:08 +00:00
function theme_status_report ( $variables ) {
$requirements = $variables [ 'requirements' ];
2010-10-09 05:18:53 +00:00
$severities = array (
REQUIREMENT_INFO => array (
'title' => t ( 'Info' ),
'class' => 'info' ,
),
REQUIREMENT_OK => array (
'title' => t ( 'OK' ),
'class' => 'ok' ,
),
REQUIREMENT_WARNING => array (
'title' => t ( 'Warning' ),
'class' => 'warning' ,
),
REQUIREMENT_ERROR => array (
'title' => t ( 'Error' ),
'class' => 'error' ,
),
);
2013-06-17 19:58:27 +00:00
$output = '<table class="system-status-report"><thead><tr class="visually-hidden">' ;
2013-02-06 12:03:53 +00:00
$output .= '<th>' . t ( 'Status' ) . '</th><th>' . t ( 'Component' ) . '</th><th>' . t ( 'Details' ) . '</th>' ;
$output .= '</tr></thead><tbody>' ;
2010-10-09 05:18:53 +00:00
2007-08-26 16:41:02 +00:00
foreach ( $requirements as $requirement ) {
2013-08-05 15:59:11 +00:00
// Always use the explicit requirement severity, if defined. Otherwise,
// default to REQUIREMENT_OK in the installer to visually confirm that
// installation requirements are met. And default to REQUIREMENT_INFO to
// denote neutral information without special visualization.
if ( isset ( $requirement [ 'severity' ])) {
$severity = $severities [( int ) $requirement [ 'severity' ]];
}
elseif ( defined ( 'MAINTENANCE_MODE' ) && MAINTENANCE_MODE == 'install' ) {
$severity = $severities [ REQUIREMENT_OK ];
}
else {
$severity = $severities [ REQUIREMENT_INFO ];
}
2013-10-25 19:28:01 +00:00
// hook_requirements does not require value to be set. Set to null if not:
if ( isset ( $requirement [ 'value' ])) {
$value = $requirement [ 'value' ];
}
else {
$value = NULL ;
}
2012-05-26 18:46:07 +00:00
2013-08-05 15:59:11 +00:00
$severity [ 'icon' ] = '<div title="' . $severity [ 'title' ] . '"><span class="visually-hidden">' . $severity [ 'title' ] . '</span></div>' ;
2007-08-26 16:41:02 +00:00
2013-08-05 15:59:11 +00:00
// Output table rows.
$output .= '<tr class="' . $severity [ 'class' ] . '">' ;
$output .= '<td class="status-icon">' . $severity [ 'icon' ] . '</td>' ;
$output .= '<td class="status-title">' . $requirement [ 'title' ] . '</td>' ;
2013-10-25 19:28:01 +00:00
$output .= '<td class="status-value">' . $value ;
2013-08-05 15:59:11 +00:00
if ( ! empty ( $requirement [ 'description' ])) {
$output .= '<div class="description">' . $requirement [ 'description' ] . '</div>' ;
2007-08-26 16:41:02 +00:00
}
2013-08-05 15:59:11 +00:00
$output .= '</td></tr>' ;
2007-08-26 16:41:02 +00:00
}
2012-05-26 18:46:07 +00:00
$output .= '</tbody></table>' ;
2007-08-26 16:41:02 +00:00
return $output ;
}
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for the modules form .
2007-08-30 15:31:46 +00:00
*
2009-10-09 01:00:08 +00:00
* @ param $variables
* An associative array containing :
2010-04-13 15:23:03 +00:00
* - form : A render element representing the form .
2009-10-09 01:00:08 +00:00
*
2007-08-26 16:41:02 +00:00
* @ ingroup themeable
*/
2012-11-27 07:06:47 +00:00
function theme_system_modules_details ( $variables ) {
2009-10-09 01:00:08 +00:00
$form = $variables [ 'form' ];
2007-08-26 16:41:02 +00:00
// Individual table headers.
2008-07-23 07:37:06 +00:00
$rows = array ();
2012-11-27 07:06:47 +00:00
// Iterate through all the modules, which are children of this element.
2008-07-23 07:37:06 +00:00
foreach ( element_children ( $form ) as $key ) {
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
// Stick the key into $module for easier access.
2008-07-23 07:37:06 +00:00
$module = $form [ $key ];
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
// Create the row for the table.
2008-07-23 07:37:06 +00:00
$row = array ();
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
// Add the checkbox into the first cell.
2008-07-23 07:37:06 +00:00
unset ( $module [ 'enable' ][ '#title' ]);
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
$module [ '#requires' ] = array_filter ( $module [ '#requires' ]);
$module [ '#required_by' ] = array_filter ( $module [ '#required_by' ]);
$requires = ! empty ( $module [ '#requires' ]);
$required_by = ! empty ( $module [ '#required_by' ]);
$version = ! empty ( $module [ 'version' ][ '#markup' ]);
2009-08-22 14:34:23 +00:00
$row [] = array ( 'class' => array ( 'checkbox' ), 'data' => drupal_render ( $module [ 'enable' ]));
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
// Add the module label and expand/collapse functionalty.
2013-04-05 16:04:10 +00:00
$col2 = '<label id="module-' . $key . '" for="' . $module [ 'enable' ][ '#id' ] . '" class="module-name table-filter-text-source">' . drupal_render ( $module [ 'name' ]) . '</label>' ;
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
$row [] = array ( 'class' => array ( 'module' ), 'data' => $col2 );
2009-01-14 12:18:37 +00:00
// Add the description, along with any modules it requires.
2013-07-10 21:44:43 +00:00
$description = '' ;
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
if ( $version || $requires || $required_by ) {
$description .= ' <div class="requirements">' ;
if ( $version ) {
$description .= '<div class="admin-requirements">' . t ( 'Version: !module-version' , array ( '!module-version' => drupal_render ( $module [ 'version' ]))) . '</div>' ;
}
if ( $requires ) {
$description .= '<div class="admin-requirements">' . t ( 'Requires: !module-list' , array ( '!module-list' => implode ( ', ' , $module [ '#requires' ]))) . '</div>' ;
}
if ( $required_by ) {
$description .= '<div class="admin-requirements">' . t ( 'Required by: !module-list' , array ( '!module-list' => implode ( ', ' , $module [ '#required_by' ]))) . '</div>' ;
}
$description .= '</div>' ;
2008-07-23 07:37:06 +00:00
}
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
$links = '' ;
2009-11-17 21:24:19 +00:00
foreach ( array ( 'help' , 'permissions' , 'configure' ) as $key ) {
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
$links .= drupal_render ( $module [ 'links' ][ $key ]);
2009-11-17 21:24:19 +00:00
}
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
if ( $links ) {
$description .= ' <div class="links">' ;
$description .= $links ;
$description .= '</div>' ;
}
2013-07-10 21:44:43 +00:00
$details = array (
'#type' => 'details' ,
'#title' => '<span class="text"> ' . drupal_render ( $module [ 'description' ]) . '</span>' ,
'#attributes' => array ( 'id' => $module [ 'enable' ][ '#id' ] . '-description' ),
'#description' => $description ,
'#collapsed' => TRUE ,
);
$col4 = drupal_render ( $details );
Issue #1790280 by nod_, Bojhan, Wim Leers, danillonunes, deviantintegral, Kiphaas7, benjifisher, sun, yoroy, Everett Zufelt, jenlampton, aspilicious: Module page redesign 2.0.
2012-11-21 19:35:03 +00:00
$row [] = array ( 'class' => array ( 'description' , 'expand' ), 'data' => $col4 );
2008-07-23 07:37:06 +00:00
$rows [] = $row ;
2007-08-26 16:41:02 +00:00
}
2013-09-25 07:49:11 +00:00
$table = array (
'#theme' => 'table' ,
'#header' => $form [ '#header' ],
'#rows' => $rows ,
);
return drupal_render ( $table );
2008-07-23 07:37:06 +00:00
}
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for a message about incompatible modules .
2009-10-09 01:00:08 +00:00
*
* @ param $variables
* An associative array containing :
* - message : The form array representing the currently disabled modules .
*
2010-04-13 15:23:03 +00:00
* @ ingroup themeable
2008-07-23 07:37:06 +00:00
*/
2009-10-09 01:00:08 +00:00
function theme_system_modules_incompatible ( $variables ) {
return '<div class="incompatible">' . $variables [ 'message' ] . '</div>' ;
2007-08-26 16:41:02 +00:00
}
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for a table of currently disabled modules .
2009-10-09 01:00:08 +00:00
*
* @ param $variables
* An associative array containing :
2010-04-13 15:23:03 +00:00
* - form : A render element representing the form .
2009-10-09 01:00:08 +00:00
*
2010-04-13 15:23:03 +00:00
* @ ingroup themeable
2007-08-26 16:41:02 +00:00
*/
2009-10-09 01:00:08 +00:00
function theme_system_modules_uninstall ( $variables ) {
$form = $variables [ 'form' ];
2007-08-26 16:41:02 +00:00
// No theming for the confirm form.
if ( isset ( $form [ 'confirm' ])) {
return drupal_render ( $form );
}
// Table headers.
$header = array ( t ( 'Uninstall' ),
t ( 'Name' ),
t ( 'Description' ),
);
// Display table.
$rows = array ();
foreach ( element_children ( $form [ 'modules' ]) as $module ) {
2013-09-19 16:22:53 +00:00
if ( ! empty ( $form [ 'modules' ][ $module ][ '#required_by' ])) {
$disabled_message = format_plural ( count ( $form [ 'modules' ][ $module ][ '#required_by' ]),
2010-11-20 03:34:30 +00:00
'To uninstall @module, the following module must be uninstalled first: @required_modules' ,
'To uninstall @module, the following modules must be uninstalled first: @required_modules' ,
2013-09-19 16:22:53 +00:00
array ( '@module' => $form [ 'modules' ][ $module ][ '#module_name' ], '@required_modules' => implode ( ', ' , $form [ 'modules' ][ $module ][ '#required_by' ])));
2010-11-20 03:34:30 +00:00
$disabled_message = '<div class="admin-requirements">' . $disabled_message . '</div>' ;
}
else {
$disabled_message = '' ;
}
2007-08-26 16:41:02 +00:00
$rows [] = array (
array ( 'data' => drupal_render ( $form [ 'uninstall' ][ $module ]), 'align' => 'center' ),
2008-04-30 06:39:26 +00:00
'<strong><label for="' . $form [ 'uninstall' ][ $module ][ '#id' ] . '">' . drupal_render ( $form [ 'modules' ][ $module ][ 'name' ]) . '</label></strong>' ,
2010-11-20 03:34:30 +00:00
array ( 'data' => drupal_render ( $form [ 'modules' ][ $module ][ 'description' ]) . $disabled_message , 'class' => array ( 'description' )),
2007-08-26 16:41:02 +00:00
);
}
2013-09-25 07:49:11 +00:00
$table = array (
'#theme' => 'table' ,
'#header' => $header ,
'#rows' => $rows ,
'#empty' => t ( 'No modules are available to uninstall.' ),
);
$output = drupal_render ( $table );
2009-02-03 18:55:32 +00:00
$output .= drupal_render_children ( $form );
2007-08-26 16:41:02 +00:00
return $output ;
}
/**
2010-04-13 15:23:03 +00:00
* Returns HTML for the Appearance page .
2007-08-26 16:41:02 +00:00
*
2009-10-09 01:00:08 +00:00
* @ param $variables
* An associative array containing :
2009-12-01 00:39:35 +00:00
* - theme_groups : An associative array containing groups of themes .
2013-09-25 07:49:11 +00:00
* - theme_group_titles : An associative array containing titles of themes .
2009-10-09 01:00:08 +00:00
*
2007-08-26 16:41:02 +00:00
* @ ingroup themeable
*/
2009-12-01 00:39:35 +00:00
function theme_system_themes_page ( $variables ) {
$theme_groups = $variables [ 'theme_groups' ];
2009-10-09 01:00:08 +00:00
2009-12-01 00:39:35 +00:00
$output = '<div id="system-themes-page">' ;
foreach ( $variables [ 'theme_group_titles' ] as $state => $title ) {
if ( ! count ( $theme_groups [ $state ])) {
// Skip this group of themes if no theme is there.
2007-08-26 16:41:02 +00:00
continue ;
}
2009-12-01 00:39:35 +00:00
// Start new theme group.
$output .= '<div class="system-themes-list system-themes-list-' . $state . ' clearfix"><h2>' . $title . '</h2>' ;
2007-08-26 16:41:02 +00:00
2010-09-28 02:30:32 +00:00
foreach ( $theme_groups [ $state ] as $theme ) {
2007-08-26 16:41:02 +00:00
2009-12-01 00:39:35 +00:00
// Theme the screenshot.
2013-07-10 18:37:49 +00:00
if ( $theme -> screenshot ) {
$image = array (
'#theme' => 'image' ,
'#uri' => $theme -> screenshot [ 'uri' ],
'#alt' => $theme -> screenshot [ 'alt' ],
'#title' => $theme -> screenshot [ 'title' ],
'#attributes' => $theme -> screenshot [ 'attributes' ],
);
$screenshot = drupal_render ( $image );
}
else {
$screenshot = '<div class="no-screenshot"><div class="no-screenshot__text">' . t ( 'no screenshot' ) . '</div></div>' ;
}
2007-08-26 16:41:02 +00:00
2009-12-01 00:39:35 +00:00
// Localize the theme description.
$description = t ( $theme -> info [ 'description' ]);
// Style theme info
$notes = count ( $theme -> notes ) ? ' (' . join ( ', ' , $theme -> notes ) . ')' : '' ;
$theme -> classes [] = 'theme-selector' ;
$theme -> classes [] = 'clearfix' ;
$output .= '<div class="' . join ( ' ' , $theme -> classes ) . '">' . $screenshot . '<div class="theme-info"><h3>' . $theme -> info [ 'name' ] . ' ' . ( isset ( $theme -> info [ 'version' ]) ? $theme -> info [ 'version' ] : '' ) . $notes . '</h3><div class="theme-description">' . $description . '</div>' ;
// Make sure to provide feedback on compatibility.
if ( ! empty ( $theme -> incompatible_core )) {
2013-09-16 03:58:06 +00:00
$output .= '<div class="incompatible">' . t ( 'This version is not compatible with Drupal !core_version and should be replaced.' , array ( '!core_version' => \Drupal :: CORE_COMPATIBILITY )) . '</div>' ;
2009-12-01 00:39:35 +00:00
}
elseif ( ! empty ( $theme -> incompatible_php )) {
if ( substr_count ( $theme -> info [ 'php' ], '.' ) < 2 ) {
$theme -> info [ 'php' ] .= '.*' ;
}
$output .= '<div class="incompatible">' . t ( 'This theme requires PHP version @php_required and is incompatible with PHP version !php_version.' , array ( '@php_required' => $theme -> info [ 'php' ], '!php_version' => phpversion ())) . '</div>' ;
}
2012-08-06 13:18:08 +00:00
elseif ( ! empty ( $theme -> incompatible_base )) {
$output .= '<div class="incompatible">' . t ( 'This theme requires the base theme @base_theme to operate correctly.' , array ( '@base_theme' => $theme -> info [ 'base theme' ])) . '</div>' ;
}
elseif ( ! empty ( $theme -> incompatible_engine )) {
$output .= '<div class="incompatible">' . t ( 'This theme requires the theme engine @theme_engine to operate correctly.' , array ( '@theme_engine' => $theme -> info [ 'engine' ])) . '</div>' ;
}
2009-12-01 00:39:35 +00:00
else {
2013-07-10 18:37:49 +00:00
$links = array (
'#theme' => 'links' ,
'#links' => $theme -> operations ,
'#attributes' => array (
'class' => array ( 'operations' , 'clearfix' ),
),
);
$output .= drupal_render ( $links );
2009-12-01 00:39:35 +00:00
}
$output .= '</div></div>' ;
2007-08-26 16:41:02 +00:00
}
2009-12-01 00:39:35 +00:00
$output .= '</div>' ;
2007-08-26 16:41:02 +00:00
}
2009-12-01 00:39:35 +00:00
$output .= '</div>' ;
2007-08-26 16:41:02 +00:00
return $output ;
2008-08-21 19:36:39 +00:00
}