-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Praesidiarius
committed
Feb 11, 2020
1 parent
2046d2d
commit 94de45e
Showing
10 changed files
with
199 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
module/Application/src/Controller/CoreUpdateController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* CoreUpdateController.php - Update DB Controller | ||
* | ||
* Main Controller DB Update for all modules | ||
* | ||
* @category Controller | ||
* @package Application | ||
* @author Verein onePlace | ||
* @copyright (C) 2020 Verein onePlace <[email protected]> | ||
* @license https://opensource.org/licenses/BSD-3-Clause | ||
* @version 1.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Application\Controller; | ||
use Laminas\Db\Adapter\AdapterInterface; | ||
use Laminas\ServiceManager\Exception\ServiceNotFoundException; | ||
use Laminas\View\Model\ViewModel; | ||
use Laminas\Db\Sql\Select; | ||
use Zend\I18n\Translator\Translator; | ||
|
||
class CoreUpdateController extends CoreController { | ||
/** | ||
* Article Table Object | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected $oTableGateway; | ||
|
||
public function __construct(AdapterInterface $oDbAdapter,$oTableGateway = false,$oServiceManager) { | ||
parent::__construct($oDbAdapter,$oTableGateway,$oServiceManager); | ||
} | ||
|
||
/** | ||
* Parse SQL File from Installer and save to database | ||
* | ||
* @param string $sFile location of sql file | ||
* @param AdapterInterface $oAdapter database connection | ||
* @since 1.0.2.1 | ||
*/ | ||
protected function parseSQLInstallFile($sFile,$oAdapter) { | ||
$templine = ''; | ||
$lines = file($sFile); | ||
// Loop through each line | ||
foreach ($lines as $line) { | ||
if (substr($line, 0, 2) == '--' || $line == '') | ||
continue; | ||
// Add this line to the current segment | ||
$templine .= $line; | ||
// If it has a semicolon at the end, it's the end of the query | ||
if (substr(trim($line), -1, 1) == ';') | ||
{ | ||
$results = $oAdapter->query($templine, $oAdapter::QUERY_MODE_EXECUTE); | ||
$templine = ''; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
module/Application/view/application/index/checkforupdates.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
?> | ||
<h2>Installed Modules</h2> | ||
<ul class="list-group"> | ||
<?php | ||
foreach($aModulesInstalled as $oMod) { | ||
$sPath = 'vendor/'.$oMod->vendor.'/'.$oMod->module_key.'/src/Module.php'; | ||
if($oMod->module_key == 'oneplace-core') { | ||
$sPath = 'module/Application/src/Module.php'; | ||
} | ||
if(file_exists($sPath)) { | ||
$sModule = str_replace(['-'],['\\'],$oMod->module_key); | ||
$sClass = "$sModule\\Module"; | ||
$sInstalledVer = '(unknown)'; | ||
if($oMod->module_key == 'oneplace-core') { | ||
$sClass = "Application\\Module"; | ||
} | ||
$sInstalledVer = $sClass::VERSION; | ||
?> | ||
<li class="list-group-item"> | ||
<?=$oMod->label?> - <?=$oMod->version?> - <?=$sClass::VERSION?> | ||
</li> | ||
<?php | ||
} | ||
?> | ||
<?php | ||
} | ||
?> | ||
<h2>New Modules to install</h2> | ||
<ul class="list-group"> | ||
<?php | ||
$aVendors = ['oneplace']; | ||
foreach($aVendors as $sVendor) { | ||
$aModules = glob('vendor/'.$sVendor.'/*', GLOB_ONLYDIR); | ||
foreach($aModules as $sMod) { | ||
$sModName = basename($sMod); | ||
if(!array_key_exists($sModName,$aModulesInstalled)) { | ||
$sPath = 'vendor/'.$sVendor.'/'.$sModName.'/src/Module.php'; | ||
if(file_exists($sPath)) { | ||
require_once $sPath; | ||
$sClass = ucfirst($sVendor)."\\".ucfirst(explode('-',$sModName)[1])."\\Module"; | ||
$sModVer = $sClass::VERSION; | ||
|
||
$sUrl = ''; | ||
try { | ||
$sModRoute = explode('-',$sModName)[1]; | ||
$sUrl = $this->url($sModRoute.'-setup'); | ||
} catch(\RuntimeException $e) { | ||
|
||
} | ||
?> | ||
<li class="list-group-item"> | ||
<?=$sModName?> - <?=$sModVer?> | ||
<?php if($sUrl != '') { ?> | ||
- <a href="<?=$sUrl?>" title="Run Setup"> | ||
Run setup | ||
</a> | ||
<?php } ?> | ||
</li> | ||
<?php | ||
} | ||
} | ||
} | ||
} | ||
?> | ||
</ul> |
File renamed without changes.
File renamed without changes.