Example #1
0
 public function updateDatabase()
 {
     $time_start = microtime(true);
     echo 'Updating Database';
     echo ' - <span style="color:green">' . JText::_('Success') . '</span>';
     echo JHtml::_('sliders.start', 'details', array('allowAllClose' => true, 'startTransition' => true, true));
     echo JHtml::_('sliders.panel', 'Details', 'panel-details');
     echo '<div style="width:100%; height: 200px; overflow: auto">';
     JoomleagueModelDatabaseTools::ImportTables();
     echo '</div>';
     echo JHtml::_('sliders.end');
     echo self::getFxInitJSCode('tables');
     echo self::getFxInitJSCode('details');
     echo '<br />';
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     if ($this->debug) {
         echo '<br>Duration: ' . round($time) . 's<br>';
     }
 }
$totalUpdateParts = 2;
setUpdatePart();
if (getUpdatePart() < $totalUpdateParts) {
    echo '<p><b>';
    echo JText::sprintf('Please remember that this update routine has totally %1$s update steps!', $totalUpdateParts) . '</b><br />';
    echo JText::_('So please go to the bottom of this page to check if there are errors and more update steps to do!');
    echo '</p>';
    echo '<p style="color:red; font-weight:bold; ">';
    echo JText::_('We recommend a database backup before the update!!!') . '<br />';
    echo '</p>';
    echo '<hr>';
}
if (getUpdatePart() == $totalUpdateParts) {
    echo '<hr />';
    require_once JPATH_ADMINISTRATOR . '/components/com_joomleague/models/databasetools.php';
    echo JoomleagueModelDatabaseTools::ImportTables();
    echo '<br /><center><hr />';
    echo JText::sprintf('Memory Limit is %1$s', ini_get('memory_limit')) . '<br />';
    echo JText::sprintf('Memory Peak Usage was %1$s Bytes', number_format(memory_get_peak_usage(true), 0, '', '.')) . '<br />';
    echo JText::sprintf('Time Limit is %1$s seconds', ini_get('max_execution_time')) . '<br />';
    $mtime = microtime();
    $mtime = explode(" ", $mtime);
    $mtime = $mtime[1] + $mtime[0];
    $endtime = $mtime;
    $totaltime = $endtime - $starttime;
    echo JText::sprintf('This page was created in %1$s seconds', $totaltime);
    echo '<hr /></center>';
    setUpdatePart(0);
} else {
    echo '<input type="button" onclick="document.body.innerHTML=\'please wait...\';location.reload(true)" value="';
    echo JText::sprintf('Click here to do step %1$s of %2$s steps to finish the update.', getUpdatePart() + 1, $totalUpdateParts);