Skip to content

Commit

Permalink
Update plugins docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcwilson committed Jul 7, 2020
1 parent b98983d commit 0a3d9e6
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
2 changes: 1 addition & 1 deletion content/dev/plugins/encapsulated_plugins/_index.md
Expand Up @@ -5,7 +5,7 @@ category: plugins
weight: 10
---

In Zen Cart v1.5.7 a Plugin Manager was added to begin allowing support for Admin-Only plugins using the new architecture.
In Zen Cart v1.5.7, a Plugin Manager was added to begin allowing support for Admin-Only plugins using the new architecture.

The plugin architecture allows plugins to be encapsulated into a hierarchical directory structure
that mimics the Zen Cart directory structure.
Expand Down
67 changes: 67 additions & 0 deletions content/dev/plugins/encapsulated_plugins/converting.md
@@ -0,0 +1,67 @@
---
title: Converting an older plugin
description:
weight: 80
layout: docs
---

**Note** For simplicity, files like `license.txt`, `README.txt` and `docs` are omitted; no changes are made to those files, which are not deployed.

Converting an older plugin to use the encapsulated architecture can be done
following these steps:

### 1. Create the plugin's file hierarchy.

As a general rule, this just means moving the files you currently have in the
plugin's top level folder under a new folder with the name
<i>Plugin Name/Version</i>.

For example, the Mod List files, prior to conversion, were:

```
./admin/includes/languages/english/extra_definitions/mod_list.php
./admin/includes/languages/english/mod_list.php
./admin/includes/extra_configures/mod_list.php
./admin/mod_list.php
```

These become:

```
./ModList/1.4.0/admin/includes/languages/english/extra_definitions/mod_list.php
./ModList/1.4.0/admin/includes/languages/english/mod_list.php
./ModList/1.4.0/admin/includes/extra_configures/mod_list.php
./ModList/1.4.0/admin/mod_list.php
```

### 2. Add the Manifest

Create a [manifest file](/dev/plugins/encapsulated_plugins/manifests/). In our example, this will be placed in

```
./ModList/1.4.0/manifest.php
```


### 3. Add the Plugin Installer script

Create an [installer script](/dev/plugins/encapsulated_plugins/installer_classes/).

In our example, this will be placed in

```
./ModList/1.4.0/Installer/PluginInstaller.php
```

### 4. (optional) Create install and uninstall files

If the installer script you created above did not do the SQL operations
required by the plugin, you can use [plain SQL files](/dev/plugins/encapsulated_plugins/sql_installation/).

In our example, these will be placed in

```
./ModList/1.4.0/Installer/uninstall.sql
./ModList/1.4.0/Installer/install.sql
```

7 changes: 4 additions & 3 deletions content/dev/plugins/encapsulated_plugins/sql_installation.md
Expand Up @@ -12,6 +12,7 @@ using a class based migration system.

## Plain SQL Files

Create a plain .sql file called `install.sql` with the SQL statements you need for installation.

CREATE TABLE IF NOT EXISTS reward_master (
rewards_products_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
Expand All @@ -38,14 +39,14 @@ The sql file should reside in

- Installer

- sqlInstall

- install.sql
- install.sql


**Warning** As Zen Cart currently uses mainly `MyIsam` tables, there is no way to safely roll back any
installer sql if an error occurs. Some support for rollback may be added later (using generated migrations).

Note that an uninstall script (called `uninstall.sql`) may be placed in the same folder.


## SQL Installer Classes

Expand Down
8 changes: 6 additions & 2 deletions content/dev/plugins/upgrading_to_1.5.md
@@ -1,5 +1,5 @@
---
title: Upgrading old plugins for 1.5 Compatibility
title: Upgrading 1.3.X era plugins
description: Upgrading old Zen Cart plugins for 1.5 Compatibility
category: plugins
weight: 1
Expand All @@ -21,6 +21,10 @@ Plugin authors can use function calls to `zen_register_admin_page()` and `zen_de
In the interest of mitigating against CSRF issues, it is necessary to use GET parameters *only* when indicating selection criteria, and NEVER when performing destructive actions or database write operations.
There is a forum thread which outlines some guidance in the process of rewriting addons in this way: https://www.zen-cart.com/showthread.php?t=184616

Forms in v1.5.0 and newer must use security tokens such as those set by properly using zen_draw_form instead of hard-coded
Forms in v1.5.0 and newer must use security tokens such as those set by properly using `zen_draw_form` instead of hard-coded
tags and must use POSTs for all CRUD actions, leaving GETs for only filter-related activities.

## Moving to the Encapsulated Plugin manager

As an recommended next step, follow the guide [Converting an older plugin](/dev/plugins/encapsulated_plugins/converting/) to use the new encapsulated plugin manager.

0 comments on commit 0a3d9e6

Please sign in to comment.