/**
  * Generates JQM pages array structuring the form into a One Page interface.
  *
  * @param array $tabs
  * @param array $args The form settings.
  * @param array $auth Authorisation to access the warehouse.
  * @return string
  */
 protected static function generateTabs($tabs, $args, $auth)
 {
     $tabHtml = array();
     $tabaliases = array();
     foreach ($tabs as $tab => $tabContent) {
         // keep track on if the tab actually has real content, so we can avoid
         // floating instructions if all the controls were removed by user profile
         // integration for example.
         $hasControls = false;
         // get a machine readable alias for the heading, if we are showing tabs
         $tabalias = 'tab-' . preg_replace('/[^a-zA-Z0-9]/', '', strtolower($tab));
         $html = '';
         $html .= static::renderOneTabContent($auth, $args, $tab, $tabContent, $tabalias, $hasControls);
         if (!empty($html) && $hasControls) {
             $tabHtml[$tab] = $html;
             $tabaliases[] = $tabalias;
         }
     }
     // Output the dynamic tab content
     $pageIdx = 0;
     foreach ($tabHtml as $tab => $tabContent) {
         $tabalias = $tabaliases[$pageIdx];
         $caption = "<h1>" . $tab . "</h1>";
         $page = static::get_blank_page($tabalias, $caption);
         $page[JQM_CONTENT][JQM_CONTENT][JQM_CONTENT][] = $tabContent;
         // Add any buttons required in a jQM footer
         if (count($tabHtml) == 1) {
             $prev = '';
             $next = '';
         } elseif ($pageIdx == 0) {
             $prev = '';
             $next = '#' . $tabaliases[$pageIdx + 1];
         } elseif ($pageIdx == count($tabHtml) - 1) {
             $prev = '#' . $tabaliases[$pageIdx - 1];
             $next = '';
         } else {
             $prev = '#' . $tabaliases[$pageIdx - 1];
             $next = '#' . $tabaliases[$pageIdx + 1];
         }
         $page[JQM_CONTENT][JQM_FOOTER][JQM_CONTENT][] = mobile_entry_helper::wizard_buttons(array('prev' => $prev, 'next' => $next));
         $pageIdx++;
         static::push_pages_array($page);
     }
 }