Skip to content

Commit

Permalink
More PHPDocs steps
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCartpenter committed May 9, 2024
1 parent 1a83024 commit 64e093f
Show file tree
Hide file tree
Showing 27 changed files with 262 additions and 5 deletions.
8 changes: 8 additions & 0 deletions upload/install/cli_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function handleError($errno, $errstr, $errfile, $errline) {

set_error_handler('handleError');

// Usage
function usage(): void {
echo "Usage:\n";
echo "======\n";
Expand Down Expand Up @@ -87,6 +88,7 @@ function usage(): void {
echo 'php cli_install.php install ' . $options . "\n\n";
}

// Get Options
function get_options($argv) {
$defaults = [
'db_hostname' => 'localhost',
Expand Down Expand Up @@ -114,6 +116,7 @@ function get_options($argv) {
return array_merge($defaults, $options);
}

// Valid
function valid($options) {
$required = [
'db_hostname',
Expand Down Expand Up @@ -148,6 +151,7 @@ function valid($options) {
];
}

// Install
function install($options): void {
$check = check_requirements();

Expand All @@ -161,6 +165,7 @@ function install($options): void {
}
}

// Check Requirements
function check_requirements() {
$error = null;

Expand Down Expand Up @@ -199,6 +204,7 @@ function check_requirements() {
return [$error === null, $error];
}

// Setup DB
function setup_db($data): void {
$db = new \DB($data['db_driver'], htmlspecialchars_decode($data['db_hostname']), htmlspecialchars_decode($data['db_username']), htmlspecialchars_decode($data['db_password']), htmlspecialchars_decode($data['db_database']), $data['db_port']);

Expand Down Expand Up @@ -259,6 +265,7 @@ function setup_db($data): void {
}
}

// Write Config Files
function write_config_files($options): void {
$output = '<?php' . "\n";
$output .= '// HTTP' . "\n";
Expand Down Expand Up @@ -339,6 +346,7 @@ function write_config_files($options): void {
fclose($file);
}

// Dir Permissions
function dir_permissions(): void {
$dirs = [
DIR_OPENCART . 'image/',
Expand Down
10 changes: 10 additions & 0 deletions upload/install/controller/3rd_party/extension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class 3rd Party Extension
*
* @package Install\Controller\3rd_Party
*/
class Controller3rdPartyExtension extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
$curl = curl_init();

Expand Down
5 changes: 5 additions & 0 deletions upload/install/controller/common/column_left.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* Class Column Left
*
* @package \Install\Controller\Common
*/
class ControllerCommonColumnLeft extends Controller {
/**
* Index
Expand Down
5 changes: 5 additions & 0 deletions upload/install/controller/common/footer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* Class Footer
*
* @package \Install\Controller\Common
*/
class ControllerCommonFooter extends Controller {
/**
* Index
Expand Down
5 changes: 5 additions & 0 deletions upload/install/controller/common/header.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* Class Header
*
* @package \Install\Controller\Common
*/
class ControllerCommonHeader extends Controller {
/**
* Index
Expand Down
10 changes: 10 additions & 0 deletions upload/install/controller/error/not_found.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class Not Found
*
* @package \Install\Controller\Error
*/
class ControllerErrorNotFound extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
/*
$this->load->language('error/not_found');
Expand Down
13 changes: 13 additions & 0 deletions upload/install/controller/event/theme.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<?php
/**
* Class Theme
*
* @package \Install\Controller\Event
*/
class ControllerEventTheme extends Controller {
/**
* Index
*
* @param mixed $view
* @param mixed $data
*
* @return void
*/
public function index(&$view, &$data): void {
if (is_file(DIR_TEMPLATE . $view . '.twig')) {
$this->config->set('template_engine', 'twig');
Expand Down
5 changes: 5 additions & 0 deletions upload/install/controller/install/promotion.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* Class Promotion
*
* @package \Install\Controller\Install
*/
class ControllerInstallPromotion extends Controller {
/**
* Index
Expand Down
10 changes: 10 additions & 0 deletions upload/install/controller/install/step_1.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class Step1
*
* @package \Install\Controller\Install
*/
class ControllerInstallStep1 extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
$this->load->language('install/step_1');

Expand Down
11 changes: 10 additions & 1 deletion upload/install/controller/install/step_4.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?php

/**
* Class Step4
*
* @package \Install\Controller\Install
*/
class ControllerInstallStep4 extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
$this->load->language('install/step_4');

Expand Down
34 changes: 31 additions & 3 deletions upload/install/controller/startup/database.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
<?php
/**
* Class Database
*
* @package \Install\Controller\Startup
*/
class ControllerStartupDatabase extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
if (is_file(DIR_OPENCART . 'config.php') && filesize(DIR_OPENCART . 'config.php') > 0) {
$lines = file(DIR_OPENCART . 'config.php');

foreach ($lines as $line) {
if (str_contains(strtoupper($line), 'DB_')) {
eval($line);
if (str_contains(strtoupper($line), 'DB_') && preg_match('/define\(\'(.*)\',\s+["\'](.*)["\']\)/', $line, $match, PREG_OFFSET_CAPTURE)) {
define($match[1][0], $match[2][0]);
}
}

if (defined('DB_SSL_KEY')) {
$db_ssl_key = DB_SSL_KEY;
} else {
$db_ssl_key = '';
}

if (defined('DB_SSL_CERT')) {
$db_ssl_cert = DB_SSL_CERT;
} else {
$db_ssl_cert = '';
}

if (defined('DB_SSL_CA')) {
$db_ssl_ca = DB_SSL_CA;
} else {
$db_ssl_ca = '';
}

if (defined('DB_PORT')) {
$port = DB_PORT;
} else {
$port = ini_get('mysqli.default_port');
}

$this->registry->set('db', new \DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, $port));
$this->registry->set('db', new \DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, $port, $db_ssl_key, $db_ssl_cert, $db_ssl_ca));
}
}
}
10 changes: 10 additions & 0 deletions upload/install/controller/startup/language.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class Language
*
* @package \Install\Controller\Startup
*/
class ControllerStartupLanguage extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
// Default language code
$code = $this->config->get('language_default');
Expand Down
5 changes: 5 additions & 0 deletions upload/install/controller/startup/router.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* Class Router
*
* @package \Install\Controller\Startup
*/
class ControllerStartupRouter extends Controller {
/**
* Index
Expand Down
10 changes: 10 additions & 0 deletions upload/install/controller/startup/upgrade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class Upgrade
*
* @package \Install\Controller\Startup
*/
class ControllerStartupUpgrade extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
$upgrade = false;

Expand Down
12 changes: 11 additions & 1 deletion upload/install/controller/upgrade/upgrade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class Upgrade
*
* @package \Install\Controller\Upgrade
*/
class ControllerUpgradeUpgrade extends Controller {
/**
* Index
*
* @return void
*/
public function index(): void {
$this->load->language('upgrade/upgrade');

Expand Down Expand Up @@ -54,7 +64,7 @@ public function next(): void {
$callable = [$this->{'model_upgrade_' . str_replace('.', '', basename($files[$step - 1], '.php'))}, 'upgrade'];

if (is_callable($callable)) {
$this->{'model_upgrade_' . str_replace('.', '', basename($files[$step - 1], '.php'))}->upgrade();
$callable();
}

$json['success'] = sprintf($this->language->get('text_progress'), basename($files[$step - 1], '.php'), $step, count($files));
Expand Down
12 changes: 12 additions & 0 deletions upload/install/model/install/install.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<?php
/**
* Class Install
*
* @package \Install\Model\Install
*/
class ModelInstallInstall extends Model {
/**
* Database
*
* @param array<string, mixed> $data
*
* @return void
*/
public function database(array $data): void {
$db = new \DB($data['db_driver'], htmlspecialchars_decode($data['db_hostname']), htmlspecialchars_decode($data['db_username']), htmlspecialchars_decode($data['db_password']), htmlspecialchars_decode($data['db_database']), $data['db_port']);

Expand Down
10 changes: 10 additions & 0 deletions upload/install/model/upgrade/1000.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class 1000
*
* @package \Install\Model\Upgrade
*/
class ModelUpgrade1000 extends Model {
/**
* Upgrade
*
* @return void
*/
public function upgrade(): void {
// This is a generic upgrade script.
// It makes mass changes to the DB by creating tables that are not in the current db, changes the charset and DB engine to the SQL schema.
Expand Down
10 changes: 10 additions & 0 deletions upload/install/model/upgrade/1001.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class 1001
*
* @package \Install\Model\Upgrade
*/
class ModelUpgrade1001 extends Model {
/**
* Upgrade
*
* @return void
*/
public function upgrade(): void {
// address
$this->db->query("ALTER TABLE `" . DB_PREFIX . "address` CHANGE `company` `company` VARCHAR(40) NOT NULL");
Expand Down
10 changes: 10 additions & 0 deletions upload/install/model/upgrade/1002.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class 1002
*
* @package \Install\Model\Upgrade
*/
class ModelUpgrade1002 extends Model {
/**
* Upgrade
*
* @return void
*/
public function upgrade(): void {
// setting
$query = $this->db->query("SELECT `setting_id` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_product_limit'");
Expand Down
10 changes: 10 additions & 0 deletions upload/install/model/upgrade/1003.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/**
* Class 1003
*
* @package \Install\Model\Upgrade
*/
class ModelUpgrade1003 extends Model {
/**
* Upgrade
*
* @return void
*/
public function upgrade(): void {
// affiliate_activity
$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "affiliate_activity'");
Expand Down
Loading

0 comments on commit 64e093f

Please sign in to comment.