git-svn-id: https://192.168.0.254/svn/Proyectos.FundacionLQDVI_WebCongresos/trunk@2 94ccb1af-fd9d-d947-8d90-7f70ea60afc8
119 lines
3.6 KiB
PHP
119 lines
3.6 KiB
PHP
<?php
|
|
/*
|
|
* @component SQL 2 Excel Component
|
|
* @copyright Copyright (C) Joomla-R-Us, joomla-r-us.com
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
|
|
*/
|
|
|
|
class Sql2excelControlPanel
|
|
{
|
|
function addButton( $link, $image, $text ) {
|
|
|
|
$button = '<div style="float:left;">';
|
|
$button .= '<div class="icon">'
|
|
.'<a href="'.$link.'">'
|
|
.JHTML::_('image.site', $image, '/components/com_sql2excel/assets/images/', NULL, NULL, $text )
|
|
.'<span>'.$text.'</span></a>'
|
|
.'</div></div>';
|
|
return $button;
|
|
}
|
|
|
|
function addLogo( ) {
|
|
|
|
$button = '';
|
|
$button .= '<div class="icon" style="width: 290px;border-bottom: black 2px solid;">'
|
|
.'<a href="http://Joomla-R-Us.com">'
|
|
.JHTML::_('image.site', 'Joomla-R-Us-logo-05.png', '/components/com_sql2excel/help/en-GB/', NULL, NULL, 'Joomla-R-Us' )
|
|
.'</a>'
|
|
.'</div>';
|
|
return $button;
|
|
}
|
|
|
|
|
|
function getVersion($defaultVer) {
|
|
|
|
$version = $defaultVer;
|
|
$xmlFN = JPATH_ADMINISTRATOR .DS. 'components'.DS.'com_sql2excel'.DS.'install.xml';
|
|
if ( file_exists($xmlFN) ) {
|
|
$xmltokens = JApplicationHelper::parseXMLInstallFile($xmlFN);
|
|
if ( is_array($xmltokens ) ) {
|
|
if ( isset( $xmltokens{'version'} ) ) {
|
|
$version = $xmltokens{'version'};
|
|
}
|
|
}
|
|
}
|
|
return $version;
|
|
}
|
|
|
|
|
|
/**
|
|
* Method to get check if a upgrade is needed
|
|
* @return empty string if no upgrade is needed. returns upgrade message if it is needed.
|
|
*/
|
|
function upgradeMessage() {
|
|
|
|
$upgrade = '<div id="upgrade" style="border: 3px solid; border-color: red; padding: 20px; margin: 10px;">
|
|
<h1 style="color: red;">' . JText::_( 'UPGRADE NEEDED!' ) . '</h1>
|
|
<p><b>' . JText::_('A previous version of SQL 2 Excel is detected. An upgrade of the SQL 2 Excel table structure is needed in order to use this version of SQL 2 Excel with your existing table data. Click on the button below to perform the upgrade.') . '</b><br></p>
|
|
<p><br> <br><a href="index.php?option=com_sql2excel&controller=sqlexcelupgrade&task=upgrade"><img src="' . JURI::base() . 'components/com_sql2excel/assets/images/upgrade_now.png"></a></p>
|
|
</div>';
|
|
|
|
|
|
// Version 0.9.2 - Check #__sql2excel_worksheets columns
|
|
$db = & JFactory::getDBO();
|
|
$query = 'SHOW COLUMNS FROM #__sql2excel_worksheets';
|
|
$db->setQuery( $query );
|
|
$cols = $db->loadObjectList();
|
|
|
|
// Pro 1.0.1, 1.1.3, 1.2.2, 1.6.0, 1.7.0, 2.1.0, 2.4.0, 2.5.0
|
|
if ( count($cols) < 40 ) {
|
|
return $upgrade;
|
|
} else {
|
|
// Pro 1.0.1 - (15)
|
|
// Pro 1.2.0 - (17)
|
|
// Pro 1.6.0 - (19)
|
|
// Pro 1.9.0 - (20)
|
|
// Pro 2.4.0 - (23)
|
|
// Pro 2.5.0 - (24)
|
|
$db = & JFactory::getDBO();
|
|
$query = 'SHOW COLUMNS FROM #__sql2excel_workbooks';
|
|
$db->setQuery( $query );
|
|
$cols = $db->loadObjectList();
|
|
|
|
if ( count($cols) < 24 ) {
|
|
return $upgrade;
|
|
} else {
|
|
if ( ! Sql2excelControlPanel::tableExists('#__sql2excel_databases') ) {
|
|
return $upgrade;
|
|
} else {
|
|
// 1.6.0 (23)
|
|
// 1.8.0 (36)
|
|
$db = & JFactory::getDBO();
|
|
$query = 'SHOW COLUMNS FROM #__sql2excel_schedules';
|
|
$db->setQuery( $query );
|
|
$cols = $db->loadObjectList();
|
|
if ( count($cols) < 36 ) {
|
|
return $upgrade;
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function tableExists($tableName) {
|
|
$db = & JFactory::getDBO();
|
|
$prefix = $db->getPrefix();
|
|
$tableName = str_replace('#__', $prefix, $tableName);
|
|
$tableList = $db->getTableList($db);
|
|
if ( in_array($tableName,$tableList) ) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
} |