Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / front / front_page.module
index 39c6a361ff7a77c6136865bbc5de8e9cf715adcd..5c3f646d7faa736149cfdb14f73c6705939a2369 100644 (file)
@@ -7,38 +7,36 @@
  * This version is for Drupal 8.
  * Earlier versions can be found at http://drupal.org/project/front.
  *
- * This module version was developed by timhilliard and various members
- * of the drupal community.
- *
  * If you have any ideas/patches or requests,
  * please post them at http://drupal.org/project/issues/front.
  */
 
 use Drupal\Core\Database\Database;
 use Drupal\Core\Render\Element;
-use \Drupal\Core\Link;
-use \Drupal\Core\Url;
+use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
  * Implements hook_help().
  */
-function front_page_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {
+function front_page_help($route_name, RouteMatchInterface $route_match) {
   switch ($route_name) {
     case 'front_page.settings':
       return t('<p>Setup custom front pages for your site.</p>');
 
-    case 'front_page.home_links':
+    case 'help.page.front_page':
       return t('<p>If a HOME link is set, the &lt;front&gt; placeholder will be replaced with this value instead of the standard front page.</p>');
   }
 }
 
 /**
+ * Parse URL including GET and fragment.
+ *
  * Function to parse a full URL including GET variables and fragment
  * to an array ready for drupal_goto(), url(), or l() functions.
  */
 function front_page_parse_url($path) {
   $url['path'] = $path;
-  $url['options'] = array();
+  $url['options'] = [];
   if (preg_match('@^(?P<path>[^?#]+)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$@', $path, $match)) {
     $url['path'] = $match['path'];
     if (!empty($match['query'])) {
@@ -102,12 +100,12 @@ function front_page_get_all() {
  * Implements hook_theme().
  */
 function front_page_theme() {
-  return array(
-    'front_page_admin_arrange_form' => array(
+  return [
+    'front_page_admin_arrange_form' => [
       'render element' => 'form',
       'function' => 'theme_front_page_admin_arrange_form',
-    ),
-  );
+    ],
+  ];
 }
 
 /**
@@ -126,57 +124,63 @@ function front_page_user_role_delete($role) {
  * @param array $variables
  *   An associative array containing:
  *   - form: A render element representing the form.
+ *
+ * @return string
+ *   Rendered admin form.
+ *
+ * @todo Refactor this function, it's a legacy way.
  */
 function theme_front_page_admin_arrange_form($variables) {
   $form = $variables['form'];
 
   // Enable the drag handles.
-  drupal_attach_tabledrag($form['roles'], array(
+  drupal_attach_tabledrag($form['roles'], [
     'table_id' => 'front-page-arrange',
     'action' => 'order',
     'relationship' => 'sibling',
     'group' => 'front-page-weight',
-  ));
+  ]);
 
-  $header = array(
+  $header = [
     t('Role'),
     t('Mode'),
     t('Preview'),
     t('Enabled'),
     t('Weight'),
-  );
+  ];
 
-  $rows = array();
+  $rows = [];
   $renderer = \Drupal::service('renderer');
   foreach (Element::children($form['roles']) as $rid) {
     $element = &$form['roles'][$rid];
 
     // Add special classes to be used for tabledrag.js.
-    $element['weight']['#attributes']['class'] = array('front-page-weight');
+    $element['weight']['#attributes']['class'] = ['front-page-weight'];
 
-    $row = array();
+    $row = [];
     $row[] = $renderer->render($element['title'], FALSE);
     $row[] = $renderer->render($element['mode'], FALSE);
     $row[] = $renderer->render($element['preview'], FALSE);
     $row[] = $renderer->render($element['enabled'], FALSE);
     $row[] = $renderer->render($element['weight'], FALSE);
 
-    $row = array_merge(array('data' => $row), $element['#attributes']);
+    $row = array_merge(['data' => $row], $element['#attributes']);
     $row['class'][] = 'draggable';
     $rows[] = $row;
   }
   $output = '';
   if (empty($rows)) {
-    $rows[] = array(array('data' => 'no roles', 'colspan' => '5'));
+    $rows[] = [['data' => 'no roles', 'colspan' => '5']];
   }
 
   $front_page_arrange = [
     '#theme' => 'table',
     '#header' => $header,
     '#rows' => $rows,
-    'attributes' => array('id' => 'front-page-arrange'),
+    'attributes' => ['id' => 'front-page-arrange'],
   ];
   $output .= $renderer->render($front_page_arrange);
   $output .= drupal_render_children($form);
+
   return $output;
 }