Completed
Push — master ( d13b22...a2d243 )
by Justin
05:45
created
system/packages/com.jukusoft.cms.plugin/extensions/eventinstaller.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 		return $this->addEvents($plugin, $install_json);
46 46
 	}
47 47
 
48
-	protected function addEvents (Plugin $plugin, array $install_json) : bool {
48
+	protected function addEvents(Plugin $plugin, array $install_json) : bool {
49 49
 		//check, if events are specified
50 50
 		if (isset($install_json['events']) && is_array($install_json['events'])) {
51 51
 			//create events
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -27,66 +27,66 @@
 block discarded – undo
27 27
 
28 28
 class EventInstaller extends PluginInstaller_Plugin {
29 29
 
30
-	public function install(Plugin $plugin, array $install_json): bool {
31
-		//add events if absent
32
-		return $this->addEvents($plugin, $install_json);
33
-	}
34
-
35
-	public function uninstall(Plugin $plugin, array $install_json): bool {
36
-		//check, if events are specified
37
-		if (isset($install_json['events']) && is_array($install_json['events'])) {
38
-			//remove all events from this plugin
39
-			Events::removePluginEvents($plugin->getName());
40
-		}
41
-
42
-		return true;
43
-	}
44
-
45
-	public function upgrade(Plugin $plugin, array $install_json): bool {
46
-		//remove events first
47
-		$this->uninstall($plugin, $install_json);
48
-
49
-		//add events if absent
50
-		return $this->addEvents($plugin, $install_json);
51
-	}
52
-
53
-	protected function addEvents (Plugin $plugin, array $install_json) : bool {
54
-		//check, if events are specified
55
-		if (isset($install_json['events']) && is_array($install_json['events'])) {
56
-			//create events
57
-			foreach ($install_json['events'] as $event) {
58
-				if (!is_array($event)) {
59
-					throw new IllegalStateException("Invalide install.json, key 'events' has to contains arrays!");
60
-				}
61
-
62
-				$event_name = $event['event'];
63
-
64
-				$type = "class_static_method";
65
-
66
-				//get type
67
-				if (isset($event['type'])) {
68
-					$type = strtolower($event['type']);
69
-				}
70
-
71
-				switch ($type) {
72
-					case "file":
73
-						throw new Exception("UnuspportedOperationException: event type 'file' is not supported yet.");
74
-						break;
75
-					case "function":
76
-						throw new Exception("UnuspportedOperationException: event type 'function' is not supported yet.");
77
-						break;
78
-					case "class_static_method":
79
-						Events::addEventClass($event_name, $event['class'], $event['method'], $plugin->getName());
80
-						break;
81
-					default:
82
-						throw new IllegalArgumentException("Unknown event type: " . $type . " (event: " . $event_name . ") in install.json of plugin '" . $plugin->getName() . "'!");
83
-						break;
84
-				}
85
-			}
86
-		}
87
-
88
-		return true;
89
-	}
30
+    public function install(Plugin $plugin, array $install_json): bool {
31
+        //add events if absent
32
+        return $this->addEvents($plugin, $install_json);
33
+    }
34
+
35
+    public function uninstall(Plugin $plugin, array $install_json): bool {
36
+        //check, if events are specified
37
+        if (isset($install_json['events']) && is_array($install_json['events'])) {
38
+            //remove all events from this plugin
39
+            Events::removePluginEvents($plugin->getName());
40
+        }
41
+
42
+        return true;
43
+    }
44
+
45
+    public function upgrade(Plugin $plugin, array $install_json): bool {
46
+        //remove events first
47
+        $this->uninstall($plugin, $install_json);
48
+
49
+        //add events if absent
50
+        return $this->addEvents($plugin, $install_json);
51
+    }
52
+
53
+    protected function addEvents (Plugin $plugin, array $install_json) : bool {
54
+        //check, if events are specified
55
+        if (isset($install_json['events']) && is_array($install_json['events'])) {
56
+            //create events
57
+            foreach ($install_json['events'] as $event) {
58
+                if (!is_array($event)) {
59
+                    throw new IllegalStateException("Invalide install.json, key 'events' has to contains arrays!");
60
+                }
61
+
62
+                $event_name = $event['event'];
63
+
64
+                $type = "class_static_method";
65
+
66
+                //get type
67
+                if (isset($event['type'])) {
68
+                    $type = strtolower($event['type']);
69
+                }
70
+
71
+                switch ($type) {
72
+                    case "file":
73
+                        throw new Exception("UnuspportedOperationException: event type 'file' is not supported yet.");
74
+                        break;
75
+                    case "function":
76
+                        throw new Exception("UnuspportedOperationException: event type 'function' is not supported yet.");
77
+                        break;
78
+                    case "class_static_method":
79
+                        Events::addEventClass($event_name, $event['class'], $event['method'], $plugin->getName());
80
+                        break;
81
+                    default:
82
+                        throw new IllegalArgumentException("Unknown event type: " . $type . " (event: " . $event_name . ") in install.json of plugin '" . $plugin->getName() . "'!");
83
+                        break;
84
+                }
85
+            }
86
+        }
87
+
88
+        return true;
89
+    }
90 90
 
91 91
 }
92 92
 
Please login to merge, or discard this patch.
system/core/classes/events.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 	protected static $isInitialized = false;
33 33
 
34
-	public static function init () {
34
+	public static function init() {
35 35
 		if (Cache::getCache()->contains("events", "events")) {
36 36
 			self::$events = Cache::getCache()->get("events", "events");
37 37
 		} else {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		self::$isInitialized = true;
61 61
 	}
62 62
 
63
-	public static function throwEvent ($name, $params = array()) {
63
+	public static function throwEvent($name, $params = array()) {
64 64
 		if (!is_array($params)) {
65 65
 			throw new IllegalArgumentException("second parameter params has to be an array.");
66 66
 		}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		}
79 79
 	}
80 80
 
81
-	protected static function executeEvent ($row, $params) {
81
+	protected static function executeEvent($row, $params) {
82 82
 		$type = strtolower($row['type']);
83 83
 		$file = $row['file'];
84 84
 		$class_name = $row['class_name'];
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		}
107 107
 	}
108 108
 
109
-	public static function addEventClass (string $event, string $class_name, string $method, string $plugin_name) {
109
+	public static function addEventClass(string $event, string $class_name, string $method, string $plugin_name) {
110 110
 		Database::getInstance()->execute("INSERT INTO `{praefix}events` (
111 111
 			`id`, `name`, `type`, `file`, `class_name`, `class_method`, `created_from`, `activated`
112 112
 		) VALUES (
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		));
120 120
 	}
121 121
 
122
-	public static function removePluginEvents (string $plugin_name) {
122
+	public static function removePluginEvents(string $plugin_name) {
123 123
 		Database::getInstance()->execute("DELETE FROM `{praefix}events` WHERE `created_from` = :created_from; ", array(
124 124
 			'created_from' => "plugin_" . $plugin_name
125 125
 		));
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -27,103 +27,103 @@
 block discarded – undo
27 27
 
28 28
 class Events {
29 29
 
30
-	protected static $events = array();
31
-
32
-	protected static $isInitialized = false;
33
-
34
-	public static function init () {
35
-		if (Cache::getCache()->contains("events", "events")) {
36
-			self::$events = Cache::getCache()->get("events", "events");
37
-		} else {
38
-			//load events from database
39
-			$rows = Database::getInstance()->listRows("SELECT * FROM `{PRAEFIX}events` WHERE `activated` = '1'; ");
40
-
41
-			//iterate through rows
42
-			foreach ($rows as $row) {
43
-				//get name of event
44
-				$name = $row['name'];
45
-
46
-				//check, if name exists in array
47
-				if (!isset(self::$events[$name])) {
48
-					self::$events[$name] = array();
49
-				}
50
-
51
-				//add row to array
52
-				self::$events[$name][] = $row;
53
-			}
54
-
55
-			//put events into cache
56
-			Cache::getCache()->put("events", "events", self::$events);
57
-		}
58
-
59
-		//set initialized flag to true
60
-		self::$isInitialized = true;
61
-	}
62
-
63
-	public static function throwEvent ($name, $params = array()) {
64
-		if (!is_array($params)) {
65
-			throw new IllegalArgumentException("second parameter params has to be an array.");
66
-		}
67
-
68
-		//check, if events was initialized first
69
-		if (!self::$isInitialized) {
70
-			//initialize events
71
-			self::init();
72
-		}
73
-
74
-		if (isset(self::$events[$name])) {
75
-			foreach (self::$events[$name] as $event) {
76
-				self::executeEvent($event, $params);
77
-			}
78
-		}
79
-	}
80
-
81
-	protected static function executeEvent ($row, $params) {
82
-		$type = strtolower($row['type']);
83
-		$file = $row['file'];
84
-		$class_name = $row['class_name'];
85
-		$class_method = $row['class_method'];
86
-
87
-		switch ($type) {
88
-			case "file":
89
-				//check, if file exists
90
-				if (file_exists(ROOT_PATH . $file)) {
91
-					require(ROOT_PATH . $file);
92
-				} else {
93
-					throw new IllegalStateException("required file for event not found: " . $file);
94
-				}
95
-
96
-				break;
97
-			case "function":
98
-				call_user_func($class_method, $params);
99
-				break;
100
-			case "class_static_method":
101
-				call_user_func(array($class_name, $class_method), $params);
102
-				break;
103
-			default:
104
-				throw new IllegalStateException("unknown event type '" . $type . "' for event '" . $row['name'] . "'!");
105
-				break;
106
-		}
107
-	}
108
-
109
-	public static function addEventClass (string $event, string $class_name, string $method, string $plugin_name) {
110
-		Database::getInstance()->execute("INSERT INTO `{praefix}events` (
30
+    protected static $events = array();
31
+
32
+    protected static $isInitialized = false;
33
+
34
+    public static function init () {
35
+        if (Cache::getCache()->contains("events", "events")) {
36
+            self::$events = Cache::getCache()->get("events", "events");
37
+        } else {
38
+            //load events from database
39
+            $rows = Database::getInstance()->listRows("SELECT * FROM `{PRAEFIX}events` WHERE `activated` = '1'; ");
40
+
41
+            //iterate through rows
42
+            foreach ($rows as $row) {
43
+                //get name of event
44
+                $name = $row['name'];
45
+
46
+                //check, if name exists in array
47
+                if (!isset(self::$events[$name])) {
48
+                    self::$events[$name] = array();
49
+                }
50
+
51
+                //add row to array
52
+                self::$events[$name][] = $row;
53
+            }
54
+
55
+            //put events into cache
56
+            Cache::getCache()->put("events", "events", self::$events);
57
+        }
58
+
59
+        //set initialized flag to true
60
+        self::$isInitialized = true;
61
+    }
62
+
63
+    public static function throwEvent ($name, $params = array()) {
64
+        if (!is_array($params)) {
65
+            throw new IllegalArgumentException("second parameter params has to be an array.");
66
+        }
67
+
68
+        //check, if events was initialized first
69
+        if (!self::$isInitialized) {
70
+            //initialize events
71
+            self::init();
72
+        }
73
+
74
+        if (isset(self::$events[$name])) {
75
+            foreach (self::$events[$name] as $event) {
76
+                self::executeEvent($event, $params);
77
+            }
78
+        }
79
+    }
80
+
81
+    protected static function executeEvent ($row, $params) {
82
+        $type = strtolower($row['type']);
83
+        $file = $row['file'];
84
+        $class_name = $row['class_name'];
85
+        $class_method = $row['class_method'];
86
+
87
+        switch ($type) {
88
+            case "file":
89
+                //check, if file exists
90
+                if (file_exists(ROOT_PATH . $file)) {
91
+                    require(ROOT_PATH . $file);
92
+                } else {
93
+                    throw new IllegalStateException("required file for event not found: " . $file);
94
+                }
95
+
96
+                break;
97
+            case "function":
98
+                call_user_func($class_method, $params);
99
+                break;
100
+            case "class_static_method":
101
+                call_user_func(array($class_name, $class_method), $params);
102
+                break;
103
+            default:
104
+                throw new IllegalStateException("unknown event type '" . $type . "' for event '" . $row['name'] . "'!");
105
+                break;
106
+        }
107
+    }
108
+
109
+    public static function addEventClass (string $event, string $class_name, string $method, string $plugin_name) {
110
+        Database::getInstance()->execute("INSERT INTO `{praefix}events` (
111 111
 			`id`, `name`, `type`, `file`, `class_name`, `class_method`, `created_from`, `activated`
112 112
 		) VALUES (
113 113
 			NULL, :event, 'CLASS_STATIC_METHOD', '', :class_name, :method, :created_from, '1'
114 114
 		) ON DUPLICATE KEY UPDATE `activated` = '1';", array(
115
-			'event' => $event,
116
-			'class_name' => $class_name,
117
-			'method' => $method,
118
-			'created_from' => "plugin_" . $plugin_name
119
-		));
120
-	}
121
-
122
-	public static function removePluginEvents (string $plugin_name) {
123
-		Database::getInstance()->execute("DELETE FROM `{praefix}events` WHERE `created_from` = :created_from; ", array(
124
-			'created_from' => "plugin_" . $plugin_name
125
-		));
126
-	}
115
+            'event' => $event,
116
+            'class_name' => $class_name,
117
+            'method' => $method,
118
+            'created_from' => "plugin_" . $plugin_name
119
+        ));
120
+    }
121
+
122
+    public static function removePluginEvents (string $plugin_name) {
123
+        Database::getInstance()->execute("DELETE FROM `{praefix}events` WHERE `created_from` = :created_from; ", array(
124
+            'created_from' => "plugin_" . $plugin_name
125
+        ));
126
+    }
127 127
 
128 128
 }
129 129
 
Please login to merge, or discard this patch.
system/core/validator/pluginname.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,24 +27,24 @@
 block discarded – undo
27 27
 
28 28
 class Validator_PluginName implements Validator_Base {
29 29
 
30
-	protected static $instance = null;
30
+    protected static $instance = null;
31 31
 
32
-	public function isValide($value): bool {
33
-		return $value === $this->validate($value);
34
-	}
32
+    public function isValide($value): bool {
33
+        return $value === $this->validate($value);
34
+    }
35 35
 
36
-	public function validate($value) {
37
-		//remove all characters except except a-z, A-Z and 0-9
38
-		return preg_replace("/[^a-zA-Z_\-0-9]+/", "", $value);
39
-	}
36
+    public function validate($value) {
37
+        //remove all characters except except a-z, A-Z and 0-9
38
+        return preg_replace("/[^a-zA-Z_\-0-9]+/", "", $value);
39
+    }
40 40
 
41
-	public static function getInstance () : Validator_PluginName {
42
-		if (self::$instance == null) {
43
-			self::$instance = new Validator_PluginName();
44
-		}
41
+    public static function getInstance () : Validator_PluginName {
42
+        if (self::$instance == null) {
43
+            self::$instance = new Validator_PluginName();
44
+        }
45 45
 
46
-		return self::$instance;
47
-	}
46
+        return self::$instance;
47
+    }
48 48
 
49 49
 }
50 50
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 		return preg_replace("/[^a-zA-Z_\-0-9]+/", "", $value);
39 39
 	}
40 40
 
41
-	public static function getInstance () : Validator_PluginName {
41
+	public static function getInstance() : Validator_PluginName {
42 42
 		if (self::$instance == null) {
43 43
 			self::$instance = new Validator_PluginName();
44 44
 		}
Please login to merge, or discard this patch.
system/packages/com.jukusoft.cms.plugin/classes/plugininstallerpage.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		return $template->getCode();
124 124
 	}
125 125
 
126
-	protected function installPlugin (Plugin $plugin) {
126
+	protected function installPlugin(Plugin $plugin) {
127 127
 		$installer = new PluginInstaller($plugin);
128 128
 
129 129
 		$res = $installer->checkRequirements();
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		return $installer->install();
140 140
 	}
141 141
 
142
-	protected function uninstallPlugin (Plugin $plugin) {
142
+	protected function uninstallPlugin(Plugin $plugin) {
143 143
 		//first check, if plugin is installed
144 144
 		if (!PluginInstaller::isPluginInstalled($plugin->getName())) {
145 145
 			return array(
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		return $installer->uninstall();
154 154
 	}
155 155
 
156
-	protected function upgradePlugin (Plugin $plugin) {
156
+	protected function upgradePlugin(Plugin $plugin) {
157 157
 		//first check, if plugin is installed
158 158
 		if (!PluginInstaller::isPluginInstalled($plugin->getName())) {
159 159
 			return array(
Please login to merge, or discard this patch.
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -27,164 +27,164 @@
 block discarded – undo
27 27
 
28 28
 class PluginInstallerPage extends PageType {
29 29
 
30
-	public function getContent(): string {
31
-		$template = new DwooTemplate("pages/plugininstaller");
32
-
33
-		$error = false;
34
-
35
-		$template->assign("error_message", "");
36
-
37
-		if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) {
38
-			//
39
-		} else {
40
-			//set error message
41
-			$template->assign("error_message", "Invalide request, no action set!");
42
-
43
-			$error = true;
44
-		}
45
-
46
-		if (!isset($_REQUEST['plugin']) || empty($_REQUEST['plugin'])) {
47
-			//set error message
48
-			$template->assign("error_message", "Invalide request, no plugin was set!");
49
-
50
-			$error = true;
51
-		}
52
-
53
-		if (!$error) {
54
-			$plugin = $_REQUEST['plugin'];
55
-			$action = $_REQUEST['action'];
56
-
57
-			//validate plugin
58
-			if (!Validator_PluginName::getInstance()->isValide($plugin)) {
59
-				//set error message
60
-				$template->assign("error_message", "Invalide plugin name '" . htmlentities($plugin) . "'!");
61
-
62
-				$error = true;
63
-			} else {
64
-				//create new instance
65
-				$plugin = new Plugin($plugin);
66
-
67
-				if (!$plugin->exists()) {
68
-					//set error message
69
-					$template->assign("error_message", "Plugin '" . htmlentities($plugin->getName()) . "' doesnt exists!");
70
-
71
-					$error = true;
72
-				} else {
73
-					//load plugin.json
74
-					$plugin->load();
75
-					$plugin->loadRow();
76
-
77
-					switch ($action) {
78
-						case "install":
79
-							//install plugin
80
-							if ($this->installPlugin($plugin) === TRUE) {
81
-								//send redirect header
82
-								header("Location: " . DomainUtils::generateURL("admin/plugins"));
83
-
84
-								$template->assign("success_message", "Plugin '" . $plugin->getName() . "' installed successfully!");
85
-							} else {
86
-								//set error message
87
-								$template->assign("error_message", "Couldnt install plugin '" . htmlentities($plugin->getName()) . "'!");
88
-							}
89
-
90
-							break;
91
-						case "uninstall":
92
-							//load database row
93
-							$plugin->loadRow();
94
-
95
-							//uninstall plugin
96
-							if ($this->uninstallPlugin($plugin) === TRUE) {
97
-								//send redirect header
98
-								header("Location: " . DomainUtils::generateURL("admin/plugins"));
99
-
100
-								$template->assign("success_message", "Plugin '" . $plugin->getName() . "' uninstalled successfully!");
101
-							} else {
102
-								//set error message
103
-								$template->assign("error_message", "Couldnt uninstall plugin '" . htmlentities($plugin) . "'!");
104
-							}
105
-
106
-							break;
107
-						case "upgrade":
108
-							//load database row
109
-							$plugin->loadRow();
110
-
111
-							//upgrade plugin
112
-							if ($this->upgradePlugin($plugin) === TRUE) {
113
-								//send redirect header
114
-								header("Location: " . DomainUtils::generateURL("admin/plugins"));
115
-
116
-								$template->assign("success_message", "Plugin '" . $plugin->getName() . "' upgraded successfully!");
117
-							} else {
118
-								//set error message
119
-								$template->assign("error_message", "Couldnt upgrade plugin '" . htmlentities($plugin) . "'!");
120
-							}
121
-
122
-							break;
123
-						default:
124
-							//set error message
125
-							$template->assign("error_message", "Unknown action type '" . htmlentities($action) . "'!");
126
-
127
-							break;
128
-					}
129
-				}
130
-			}
131
-		}
132
-
133
-		return $template->getCode();
134
-	}
135
-
136
-	protected function installPlugin (Plugin $plugin) {
137
-		$installer = new PluginInstaller($plugin);
138
-
139
-		$res = $installer->checkRequirements();
140
-
141
-		//check requirements first
142
-		if ($res !== TRUE) {
143
-			return array(
144
-				'error' => $res
145
-			);
146
-		}
147
-
148
-		//check, if plugin is already installed
149
-		if ($plugin->isInstalled()) {
150
-			return false;
151
-		}
152
-
153
-		//try to install plugin
154
-		return $installer->install();
155
-	}
156
-
157
-	protected function uninstallPlugin (Plugin $plugin) {
158
-		//first check, if plugin is installed
159
-		if (!PluginInstaller::isPluginInstalled($plugin->getName())) {
160
-			return array(
161
-				'error' => "plugin_not_installed"
162
-			);
163
-		}
164
-
165
-		$installer = new PluginInstaller($plugin);
166
-
167
-		//try to uninstall plugin
168
-		return $installer->uninstall();
169
-	}
170
-
171
-	protected function upgradePlugin (Plugin $plugin) {
172
-		//first check, if plugin is installed
173
-		if (!PluginInstaller::isPluginInstalled($plugin->getName())) {
174
-			return array(
175
-				'error' => "plugin_not_installed"
176
-			);
177
-		}
178
-
179
-		$installer = new PluginInstaller($plugin);
180
-
181
-		//try to uninstall plugin
182
-		return $installer->upgrade();
183
-	}
184
-
185
-	public function listRequiredPermissions(): array {
186
-		return array("can_install_plugins");
187
-	}
30
+    public function getContent(): string {
31
+        $template = new DwooTemplate("pages/plugininstaller");
32
+
33
+        $error = false;
34
+
35
+        $template->assign("error_message", "");
36
+
37
+        if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) {
38
+            //
39
+        } else {
40
+            //set error message
41
+            $template->assign("error_message", "Invalide request, no action set!");
42
+
43
+            $error = true;
44
+        }
45
+
46
+        if (!isset($_REQUEST['plugin']) || empty($_REQUEST['plugin'])) {
47
+            //set error message
48
+            $template->assign("error_message", "Invalide request, no plugin was set!");
49
+
50
+            $error = true;
51
+        }
52
+
53
+        if (!$error) {
54
+            $plugin = $_REQUEST['plugin'];
55
+            $action = $_REQUEST['action'];
56
+
57
+            //validate plugin
58
+            if (!Validator_PluginName::getInstance()->isValide($plugin)) {
59
+                //set error message
60
+                $template->assign("error_message", "Invalide plugin name '" . htmlentities($plugin) . "'!");
61
+
62
+                $error = true;
63
+            } else {
64
+                //create new instance
65
+                $plugin = new Plugin($plugin);
66
+
67
+                if (!$plugin->exists()) {
68
+                    //set error message
69
+                    $template->assign("error_message", "Plugin '" . htmlentities($plugin->getName()) . "' doesnt exists!");
70
+
71
+                    $error = true;
72
+                } else {
73
+                    //load plugin.json
74
+                    $plugin->load();
75
+                    $plugin->loadRow();
76
+
77
+                    switch ($action) {
78
+                        case "install":
79
+                            //install plugin
80
+                            if ($this->installPlugin($plugin) === TRUE) {
81
+                                //send redirect header
82
+                                header("Location: " . DomainUtils::generateURL("admin/plugins"));
83
+
84
+                                $template->assign("success_message", "Plugin '" . $plugin->getName() . "' installed successfully!");
85
+                            } else {
86
+                                //set error message
87
+                                $template->assign("error_message", "Couldnt install plugin '" . htmlentities($plugin->getName()) . "'!");
88
+                            }
89
+
90
+                            break;
91
+                        case "uninstall":
92
+                            //load database row
93
+                            $plugin->loadRow();
94
+
95
+                            //uninstall plugin
96
+                            if ($this->uninstallPlugin($plugin) === TRUE) {
97
+                                //send redirect header
98
+                                header("Location: " . DomainUtils::generateURL("admin/plugins"));
99
+
100
+                                $template->assign("success_message", "Plugin '" . $plugin->getName() . "' uninstalled successfully!");
101
+                            } else {
102
+                                //set error message
103
+                                $template->assign("error_message", "Couldnt uninstall plugin '" . htmlentities($plugin) . "'!");
104
+                            }
105
+
106
+                            break;
107
+                        case "upgrade":
108
+                            //load database row
109
+                            $plugin->loadRow();
110
+
111
+                            //upgrade plugin
112
+                            if ($this->upgradePlugin($plugin) === TRUE) {
113
+                                //send redirect header
114
+                                header("Location: " . DomainUtils::generateURL("admin/plugins"));
115
+
116
+                                $template->assign("success_message", "Plugin '" . $plugin->getName() . "' upgraded successfully!");
117
+                            } else {
118
+                                //set error message
119
+                                $template->assign("error_message", "Couldnt upgrade plugin '" . htmlentities($plugin) . "'!");
120
+                            }
121
+
122
+                            break;
123
+                        default:
124
+                            //set error message
125
+                            $template->assign("error_message", "Unknown action type '" . htmlentities($action) . "'!");
126
+
127
+                            break;
128
+                    }
129
+                }
130
+            }
131
+        }
132
+
133
+        return $template->getCode();
134
+    }
135
+
136
+    protected function installPlugin (Plugin $plugin) {
137
+        $installer = new PluginInstaller($plugin);
138
+
139
+        $res = $installer->checkRequirements();
140
+
141
+        //check requirements first
142
+        if ($res !== TRUE) {
143
+            return array(
144
+                'error' => $res
145
+            );
146
+        }
147
+
148
+        //check, if plugin is already installed
149
+        if ($plugin->isInstalled()) {
150
+            return false;
151
+        }
152
+
153
+        //try to install plugin
154
+        return $installer->install();
155
+    }
156
+
157
+    protected function uninstallPlugin (Plugin $plugin) {
158
+        //first check, if plugin is installed
159
+        if (!PluginInstaller::isPluginInstalled($plugin->getName())) {
160
+            return array(
161
+                'error' => "plugin_not_installed"
162
+            );
163
+        }
164
+
165
+        $installer = new PluginInstaller($plugin);
166
+
167
+        //try to uninstall plugin
168
+        return $installer->uninstall();
169
+    }
170
+
171
+    protected function upgradePlugin (Plugin $plugin) {
172
+        //first check, if plugin is installed
173
+        if (!PluginInstaller::isPluginInstalled($plugin->getName())) {
174
+            return array(
175
+                'error' => "plugin_not_installed"
176
+            );
177
+        }
178
+
179
+        $installer = new PluginInstaller($plugin);
180
+
181
+        //try to uninstall plugin
182
+        return $installer->upgrade();
183
+    }
184
+
185
+    public function listRequiredPermissions(): array {
186
+        return array("can_install_plugins");
187
+    }
188 188
 
189 189
 }
190 190
 
Please login to merge, or discard this patch.
system/packages/com.jukusoft.cms.plugin/classes/pluginspage.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 				'support_mail' => $plugin->getSupportMail(),
61 61
 				'support_links' => $plugin->listSupportLinks(),
62 62
 				'compatible' => $installer->checkRequirements(true),
63
-				'uptodate' => true,//TODO: check, if plugin is newest version
63
+				'uptodate' => true, //TODO: check, if plugin is newest version
64 64
 				'alpha' => $plugin->isAlpha(),
65 65
 				'beta' => $plugin->isBeta(),
66 66
 				'installed' => false,
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				'support_mail' => $plugin->getSupportMail(),
100 100
 				'support_links' => $plugin->listSupportLinks(),
101 101
 				'compatible' => $installer->checkRequirements(true),
102
-				'uptodate' => true,//TODO: check, if plugin is newest version
102
+				'uptodate' => true, //TODO: check, if plugin is newest version
103 103
 				'alpha' => $plugin->isAlpha(),
104 104
 				'beta' => $plugin->isBeta(),
105 105
 				'installed' => false,
Please login to merge, or discard this patch.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -27,92 +27,92 @@  discard block
 block discarded – undo
27 27
 
28 28
 class PluginsPage extends PageType {
29 29
 
30
-	public function getContent(): string {
31
-		$template = new DwooTemplate("pages/plugins");
32
-
33
-		//get list with installed plugins
34
-		$installed_plugins = Plugins::listInstalledPlugins();
35
-
36
-		$array = array();
37
-
38
-		$lang_token = substr(Registry::singleton()->getSetting("lang_token"), 0, 2);
39
-
40
-		foreach ($installed_plugins as $plugin) {
41
-			$plugin = Plugin::castPlugin($plugin);
42
-
43
-			//create new instance of PluginInstaller to check plugin compatibility
44
-			$installer = new PluginInstaller($plugin);
45
-
46
-			$array[] = array(
47
-				'name' => $plugin->getName(),
48
-				'title' => $plugin->getTitle(),
49
-				'description' => $plugin->getDescription($lang_token),
50
-				'version' => $plugin->getVersion(),
51
-				'installed_version' => $plugin->getInstalledVersion(),
52
-				'homepage' => $plugin->getHomepage(),
53
-				'authors' => $plugin->listAuthors(),
54
-				'license' => $plugin->getLicense(),
55
-				'keywords' => $plugin->listKeywords(),
56
-				'categories' => $plugin->listCategories(),
57
-				'text' => "",
58
-				'issues' => $plugin->getIssuesLink(),
59
-				'source' => $plugin->getSourceLink(),
60
-				'support_mail' => $plugin->getSupportMail(),
61
-				'support_links' => $plugin->listSupportLinks(),
62
-				'compatible' => $installer->checkRequirements(true),
63
-				'uptodate' => true,//TODO: check, if plugin is newest version
64
-				'alpha' => $plugin->isAlpha(),
65
-				'beta' => $plugin->isBeta(),
66
-				'installed' => false,
67
-				'activated' => $plugin->isActivated()
68
-			);
69
-		}
70
-
71
-		//assign list with installed plugins
72
-		$template->assign("installed_plugins", $array);
73
-
74
-		//get list with all uninstalled plugins
75
-		$plugins = Plugins::listUninstalledPlugins();
76
-
77
-		$plugin_list = array();
78
-
79
-		foreach ($plugins as $plugin) {
80
-			$plugin = Plugin::castPlugin($plugin);
81
-
82
-			//create new instance of PluginInstaller to check plugin compatibility
83
-			$installer = new PluginInstaller($plugin);
84
-
85
-			$plugin_list[] = array(
86
-				'name' => $plugin->getName(),
87
-				'title' => $plugin->getTitle(),
88
-				'description' => $plugin->getDescription($lang_token),
89
-				'version' => $plugin->getVersion(),
90
-				'homepage' => $plugin->getHomepage(),
91
-				'authors' => $plugin->listAuthors(),
92
-				'license' => $plugin->getLicense(),
93
-				'keywords' => $plugin->listKeywords(),
94
-				'categories' => $plugin->listCategories(),
95
-				'text' => "",
96
-				'issues' => $plugin->getIssuesLink(),
97
-				'source' => $plugin->getSourceLink(),
98
-				'support_mail' => $plugin->getSupportMail(),
99
-				'support_links' => $plugin->listSupportLinks(),
100
-				'compatible' => $installer->checkRequirements(true),
101
-				'uptodate' => true,//TODO: check, if plugin is newest version
102
-				'alpha' => $plugin->isAlpha(),
103
-				'beta' => $plugin->isBeta(),
104
-				'installed' => false,
105
-				'activated' => $plugin->isActivated()
106
-			);
107
-		}
108
-
109
-		$template->assign("plugins", $plugin_list);
110
-
111
-		return $template->getCode();
112
-	}
113
-
114
-	public function getFooterScripts(): string {
115
-		return "<!-- page script -->
30
+    public function getContent(): string {
31
+        $template = new DwooTemplate("pages/plugins");
32
+
33
+        //get list with installed plugins
34
+        $installed_plugins = Plugins::listInstalledPlugins();
35
+
36
+        $array = array();
37
+
38
+        $lang_token = substr(Registry::singleton()->getSetting("lang_token"), 0, 2);
39
+
40
+        foreach ($installed_plugins as $plugin) {
41
+            $plugin = Plugin::castPlugin($plugin);
42
+
43
+            //create new instance of PluginInstaller to check plugin compatibility
44
+            $installer = new PluginInstaller($plugin);
45
+
46
+            $array[] = array(
47
+                'name' => $plugin->getName(),
48
+                'title' => $plugin->getTitle(),
49
+                'description' => $plugin->getDescription($lang_token),
50
+                'version' => $plugin->getVersion(),
51
+                'installed_version' => $plugin->getInstalledVersion(),
52
+                'homepage' => $plugin->getHomepage(),
53
+                'authors' => $plugin->listAuthors(),
54
+                'license' => $plugin->getLicense(),
55
+                'keywords' => $plugin->listKeywords(),
56
+                'categories' => $plugin->listCategories(),
57
+                'text' => "",
58
+                'issues' => $plugin->getIssuesLink(),
59
+                'source' => $plugin->getSourceLink(),
60
+                'support_mail' => $plugin->getSupportMail(),
61
+                'support_links' => $plugin->listSupportLinks(),
62
+                'compatible' => $installer->checkRequirements(true),
63
+                'uptodate' => true,//TODO: check, if plugin is newest version
64
+                'alpha' => $plugin->isAlpha(),
65
+                'beta' => $plugin->isBeta(),
66
+                'installed' => false,
67
+                'activated' => $plugin->isActivated()
68
+            );
69
+        }
70
+
71
+        //assign list with installed plugins
72
+        $template->assign("installed_plugins", $array);
73
+
74
+        //get list with all uninstalled plugins
75
+        $plugins = Plugins::listUninstalledPlugins();
76
+
77
+        $plugin_list = array();
78
+
79
+        foreach ($plugins as $plugin) {
80
+            $plugin = Plugin::castPlugin($plugin);
81
+
82
+            //create new instance of PluginInstaller to check plugin compatibility
83
+            $installer = new PluginInstaller($plugin);
84
+
85
+            $plugin_list[] = array(
86
+                'name' => $plugin->getName(),
87
+                'title' => $plugin->getTitle(),
88
+                'description' => $plugin->getDescription($lang_token),
89
+                'version' => $plugin->getVersion(),
90
+                'homepage' => $plugin->getHomepage(),
91
+                'authors' => $plugin->listAuthors(),
92
+                'license' => $plugin->getLicense(),
93
+                'keywords' => $plugin->listKeywords(),
94
+                'categories' => $plugin->listCategories(),
95
+                'text' => "",
96
+                'issues' => $plugin->getIssuesLink(),
97
+                'source' => $plugin->getSourceLink(),
98
+                'support_mail' => $plugin->getSupportMail(),
99
+                'support_links' => $plugin->listSupportLinks(),
100
+                'compatible' => $installer->checkRequirements(true),
101
+                'uptodate' => true,//TODO: check, if plugin is newest version
102
+                'alpha' => $plugin->isAlpha(),
103
+                'beta' => $plugin->isBeta(),
104
+                'installed' => false,
105
+                'activated' => $plugin->isActivated()
106
+            );
107
+        }
108
+
109
+        $template->assign("plugins", $plugin_list);
110
+
111
+        return $template->getCode();
112
+    }
113
+
114
+    public function getFooterScripts(): string {
115
+        return "<!-- page script -->
116 116
 			<script>
117 117
 				$(function () {
118 118
 					/*$('#example1').DataTable();*/
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 					});
135 135
 				});
136 136
 			</script>";
137
-	}
137
+    }
138 138
 
139 139
 }
140 140
 
Please login to merge, or discard this patch.
system/packages/com.jukusoft.cms.plugin/extensions/folderinstaller.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -27,34 +27,34 @@
 block discarded – undo
27 27
 
28 28
 class FolderInstaller extends PluginInstaller_Plugin {
29 29
 
30
-	public function install(Plugin $plugin, array $install_json): bool {
31
-		if (isset($install_json['folders'])) {
32
-			foreach ($install_json['folders'] as $folder) {
33
-				$name = $folder['folder'];
34
-				$hidden = (isset($folder['hidden']) ? boolval($folder['hidden']) : false);
35
-				$permissions = (isset($folder['permissions']) ? $folder['permissions'] : array("none"));
36
-				$main_menu = (isset($folder['main_menu']) ? intval($folder['main_menu']) : -1);
37
-				$local_menu = (isset($folder['local_menu']) ? intval($folder['local_menu']) : -1);
38
-				$force_template = (isset($folder['force_template']) ? $folder['force_template'] : "none");
39
-				$title_translation = (isset($folder['title_translation']) ? boolval($folder['title_translation']) : true);
40
-
41
-				//create folder
42
-				Folder::createFolderIfAbsent($name, $hidden, $permissions, $main_menu, $local_menu, $force_template, $title_translation);
43
-			}
44
-		}
45
-
46
-		return true;
47
-	}
48
-
49
-	public function uninstall(Plugin $plugin, array $install_json): bool {
50
-		//folders will not removed, because they can contain pages
51
-		return true;
52
-	}
53
-
54
-	public function upgrade(Plugin $plugin, array $install_json): bool {
55
-		//install supports ON DUPLICATE KEY
56
-		return $this->install($plugin, $install_json);
57
-	}
30
+    public function install(Plugin $plugin, array $install_json): bool {
31
+        if (isset($install_json['folders'])) {
32
+            foreach ($install_json['folders'] as $folder) {
33
+                $name = $folder['folder'];
34
+                $hidden = (isset($folder['hidden']) ? boolval($folder['hidden']) : false);
35
+                $permissions = (isset($folder['permissions']) ? $folder['permissions'] : array("none"));
36
+                $main_menu = (isset($folder['main_menu']) ? intval($folder['main_menu']) : -1);
37
+                $local_menu = (isset($folder['local_menu']) ? intval($folder['local_menu']) : -1);
38
+                $force_template = (isset($folder['force_template']) ? $folder['force_template'] : "none");
39
+                $title_translation = (isset($folder['title_translation']) ? boolval($folder['title_translation']) : true);
40
+
41
+                //create folder
42
+                Folder::createFolderIfAbsent($name, $hidden, $permissions, $main_menu, $local_menu, $force_template, $title_translation);
43
+            }
44
+        }
45
+
46
+        return true;
47
+    }
48
+
49
+    public function uninstall(Plugin $plugin, array $install_json): bool {
50
+        //folders will not removed, because they can contain pages
51
+        return true;
52
+    }
53
+
54
+    public function upgrade(Plugin $plugin, array $install_json): bool {
55
+        //install supports ON DUPLICATE KEY
56
+        return $this->install($plugin, $install_json);
57
+    }
58 58
 
59 59
 }
60 60
 
Please login to merge, or discard this patch.
system/packages/com.jukusoft.cms.plugin/extensions/permissioninstaller.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,39 +27,39 @@
 block discarded – undo
27 27
 
28 28
 class PermissionInstaller extends PluginInstaller_Plugin {
29 29
 
30
-	public function install(Plugin $plugin, array $install_json): bool {
31
-		if (isset($install_json['permissions'])) {
32
-			$permissions = $install_json['permissions'];
30
+    public function install(Plugin $plugin, array $install_json): bool {
31
+        if (isset($install_json['permissions'])) {
32
+            $permissions = $install_json['permissions'];
33 33
 
34
-			foreach ($permissions as $permission) {
35
-				$token = $permission['token'];
36
-				$title = $permission['title'];
37
-				$description = $permission['description'];
38
-				$category = (isset($permission['category']) ? $permission['category'] : "plugins");
39
-				$order = (isset($permission['order']) ? intval($permission['order']) : 100);
34
+            foreach ($permissions as $permission) {
35
+                $token = $permission['token'];
36
+                $title = $permission['title'];
37
+                $description = $permission['description'];
38
+                $category = (isset($permission['category']) ? $permission['category'] : "plugins");
39
+                $order = (isset($permission['order']) ? intval($permission['order']) : 100);
40 40
 
41
-				Permissions::createPermission($token, $title, $description, $category, "plugin_" . $plugin->getName(), $order);
42
-			}
43
-		}
41
+                Permissions::createPermission($token, $title, $description, $category, "plugin_" . $plugin->getName(), $order);
42
+            }
43
+        }
44 44
 
45
-		return true;
46
-	}
45
+        return true;
46
+    }
47 47
 
48
-	public function uninstall(Plugin $plugin, array $install_json): bool {
49
-		//delete permissions with plugin owner
50
-		if (isset($install_json['permissions'])) {
51
-			Permissions::deletePermissionsByOwner("plugin_" . $plugin->getName());
52
-		}
48
+    public function uninstall(Plugin $plugin, array $install_json): bool {
49
+        //delete permissions with plugin owner
50
+        if (isset($install_json['permissions'])) {
51
+            Permissions::deletePermissionsByOwner("plugin_" . $plugin->getName());
52
+        }
53 53
 
54
-		return true;
55
-	}
54
+        return true;
55
+    }
56 56
 
57
-	public function upgrade(Plugin $plugin, array $install_json): bool {
58
-		//TODO: remove permissions, which arent longer in install json
57
+    public function upgrade(Plugin $plugin, array $install_json): bool {
58
+        //TODO: remove permissions, which arent longer in install json
59 59
 
60
-		//install queries supports ON DUPLICATE KEY
61
-		return $this->install($plugin, $install_json);
62
-	}
60
+        //install queries supports ON DUPLICATE KEY
61
+        return $this->install($plugin, $install_json);
62
+    }
63 63
 
64 64
 }
65 65
 
Please login to merge, or discard this patch.
plugins/advancedpagetypes/parsedown-1.7.1/Parsedown.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1687,8 +1687,8 @@
 block discarded – undo
1687 1687
         'q', 'rt', 'ins', 'font',          'strong',
1688 1688
         's', 'tt', 'kbd', 'mark',
1689 1689
         'u', 'xm', 'sub', 'nobr',
1690
-                   'sup', 'ruby',
1691
-                   'var', 'span',
1692
-                   'wbr', 'time',
1690
+                    'sup', 'ruby',
1691
+                    'var', 'span',
1692
+                    'wbr', 'time',
1693 1693
     );
1694 1694
 }
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
             while (isset($line[$indent]) and $line[$indent] === ' ')
195 195
             {
196
-                $indent ++;
196
+                $indent++;
197 197
             }
198 198
 
199 199
             $text = $indent > 0 ? substr($line, $indent) : $line;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
             if (isset($CurrentBlock['continuable']))
208 208
             {
209
-                $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
209
+                $Block = $this->{'block' . $CurrentBlock['type'] . 'Continue'}($Line, $CurrentBlock);
210 210
 
211 211
                 if (isset($Block))
212 212
                 {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 {
219 219
                     if ($this->isBlockCompletable($CurrentBlock['type']))
220 220
                     {
221
-                        $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
221
+                        $CurrentBlock = $this->{'block' . $CurrentBlock['type'] . 'Complete'}($CurrentBlock);
222 222
                     }
223 223
                 }
224 224
             }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
             {
236 236
                 foreach ($this->BlockTypes[$marker] as $blockType)
237 237
                 {
238
-                    $blockTypes []= $blockType;
238
+                    $blockTypes [] = $blockType;
239 239
                 }
240 240
             }
241 241
 
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 
245 245
             foreach ($blockTypes as $blockType)
246 246
             {
247
-                $Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
247
+                $Block = $this->{'block' . $blockType}($Line, $CurrentBlock);
248 248
 
249 249
                 if (isset($Block))
250 250
                 {
251 251
                     $Block['type'] = $blockType;
252 252
 
253
-                    if ( ! isset($Block['identified']))
253
+                    if (!isset($Block['identified']))
254 254
                     {
255
-                        $Blocks []= $CurrentBlock;
255
+                        $Blocks [] = $CurrentBlock;
256 256
 
257 257
                         $Block['identified'] = true;
258 258
                     }
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
 
271 271
             # ~
272 272
 
273
-            if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
273
+            if (isset($CurrentBlock) and !isset($CurrentBlock['type']) and !isset($CurrentBlock['interrupted']))
274 274
             {
275
-                $CurrentBlock['element']['text'] .= "\n".$text;
275
+                $CurrentBlock['element']['text'] .= "\n" . $text;
276 276
             }
277 277
             else
278 278
             {
279
-                $Blocks []= $CurrentBlock;
279
+                $Blocks [] = $CurrentBlock;
280 280
 
281 281
                 $CurrentBlock = $this->paragraph($Line);
282 282
 
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 
289 289
         if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
290 290
         {
291
-            $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
291
+            $CurrentBlock = $this->{'block' . $CurrentBlock['type'] . 'Complete'}($CurrentBlock);
292 292
         }
293 293
 
294 294
         # ~
295 295
 
296
-        $Blocks []= $CurrentBlock;
296
+        $Blocks [] = $CurrentBlock;
297 297
 
298 298
         unset($Blocks[0]);
299 299
 
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 
322 322
     protected function isBlockContinuable($Type)
323 323
     {
324
-        return method_exists($this, 'block'.$Type.'Continue');
324
+        return method_exists($this, 'block' . $Type . 'Continue');
325 325
     }
326 326
 
327 327
     protected function isBlockCompletable($Type)
328 328
     {
329
-        return method_exists($this, 'block'.$Type.'Complete');
329
+        return method_exists($this, 'block' . $Type . 'Complete');
330 330
     }
331 331
 
332 332
     #
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
     protected function blockCode($Line, $Block = null)
336 336
     {
337
-        if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
337
+        if (isset($Block) and !isset($Block['type']) and !isset($Block['interrupted']))
338 338
         {
339 339
             return;
340 340
         }
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 
436 436
     protected function blockFencedCode($Line)
437 437
     {
438
-        if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([^`]+)?[ ]*$/', $Line['text'], $matches))
438
+        if (preg_match('/^[' . $Line['text'][0] . ']{3,}[ ]*([^`]+)?[ ]*$/', $Line['text'], $matches))
439 439
         {
440 440
             $Element = array(
441 441
                 'name' => 'code',
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
             if (isset($matches[1]))
446 446
             {
447
-                $class = 'language-'.$matches[1];
447
+                $class = 'language-' . $matches[1];
448 448
 
449 449
                 $Element['attributes'] = array(
450 450
                     'class' => $class,
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
             unset($Block['interrupted']);
479 479
         }
480 480
 
481
-        if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
481
+        if (preg_match('/^' . $Block['char'] . '{3,}[ ]*$/', $Line['text']))
482 482
         {
483 483
             $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
484 484
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
             return $Block;
488 488
         }
489 489
 
490
-        $Block['element']['text']['text'] .= "\n".$Line['body'];
490
+        $Block['element']['text']['text'] .= "\n" . $Line['body'];
491 491
 
492 492
         return $Block;
493 493
     }
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
             while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
514 514
             {
515
-                $level ++;
515
+                $level++;
516 516
             }
517 517
 
518 518
             if ($level > 6)
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
     {
542 542
         list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
543 543
 
544
-        if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
544
+        if (preg_match('/^(' . $pattern . '[ ]+)(.*)/', $Line['text'], $matches))
545 545
         {
546 546
             $Block = array(
547 547
                 'indent' => $Line['indent'],
@@ -552,11 +552,11 @@  discard block
 block discarded – undo
552 552
                 ),
553 553
             );
554 554
 
555
-            if($name === 'ol')
555
+            if ($name === 'ol')
556 556
             {
557 557
                 $listStart = stristr($matches[0], '.', true);
558 558
 
559
-                if($listStart !== '1')
559
+                if ($listStart !== '1')
560 560
                 {
561 561
                     $Block['element']['attributes'] = array('start' => $listStart);
562 562
                 }
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                 ),
571 571
             );
572 572
 
573
-            $Block['element']['text'] []= & $Block['li'];
573
+            $Block['element']['text'] [] = & $Block['li'];
574 574
 
575 575
             return $Block;
576 576
         }
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
 
579 579
     protected function blockListContinue($Line, array $Block)
580 580
     {
581
-        if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
581
+        if ($Block['indent'] === $Line['indent'] and preg_match('/^' . $Block['pattern'] . '(?:[ ]+(.*)|$)/', $Line['text'], $matches))
582 582
         {
583 583
             if (isset($Block['interrupted']))
584 584
             {
585
-                $Block['li']['text'] []= '';
585
+                $Block['li']['text'] [] = '';
586 586
 
587 587
                 $Block['loose'] = true;
588 588
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
                 ),
602 602
             );
603 603
 
604
-            $Block['element']['text'] []= & $Block['li'];
604
+            $Block['element']['text'] [] = & $Block['li'];
605 605
 
606 606
             return $Block;
607 607
         }
@@ -611,22 +611,22 @@  discard block
 block discarded – undo
611 611
             return $Block;
612 612
         }
613 613
 
614
-        if ( ! isset($Block['interrupted']))
614
+        if (!isset($Block['interrupted']))
615 615
         {
616 616
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
617 617
 
618
-            $Block['li']['text'] []= $text;
618
+            $Block['li']['text'] [] = $text;
619 619
 
620 620
             return $Block;
621 621
         }
622 622
 
623 623
         if ($Line['indent'] > 0)
624 624
         {
625
-            $Block['li']['text'] []= '';
625
+            $Block['li']['text'] [] = '';
626 626
 
627 627
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
628 628
 
629
-            $Block['li']['text'] []= $text;
629
+            $Block['li']['text'] [] = $text;
630 630
 
631 631
             unset($Block['interrupted']);
632 632
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
             {
643 643
                 if (end($li['text']) !== '')
644 644
                 {
645
-                    $li['text'] []= '';
645
+                    $li['text'] [] = '';
646 646
                 }
647 647
             }
648 648
         }
@@ -675,19 +675,19 @@  discard block
 block discarded – undo
675 675
         {
676 676
             if (isset($Block['interrupted']))
677 677
             {
678
-                $Block['element']['text'] []= '';
678
+                $Block['element']['text'] [] = '';
679 679
 
680 680
                 unset($Block['interrupted']);
681 681
             }
682 682
 
683
-            $Block['element']['text'] []= $matches[1];
683
+            $Block['element']['text'] [] = $matches[1];
684 684
 
685 685
             return $Block;
686 686
         }
687 687
 
688
-        if ( ! isset($Block['interrupted']))
688
+        if (!isset($Block['interrupted']))
689 689
         {
690
-            $Block['element']['text'] []= $Line['text'];
690
+            $Block['element']['text'] [] = $Line['text'];
691 691
 
692 692
             return $Block;
693 693
         }
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
     protected function blockRule($Line)
700 700
     {
701
-        if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
701
+        if (preg_match('/^([' . $Line['text'][0] . '])([ ]*\1){2,}[ ]*$/', $Line['text']))
702 702
         {
703 703
             $Block = array(
704 704
                 'element' => array(
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 
716 716
     protected function blockSetextHeader($Line, array $Block = null)
717 717
     {
718
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
718
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
719 719
         {
720 720
             return;
721 721
         }
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
             return;
739 739
         }
740 740
 
741
-        if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
741
+        if (preg_match('/^<(\w[\w-]*)(?:[ ]*' . $this->regexHtmlAttribute . ')*[ ]*(\/)?>/', $Line['text'], $matches))
742 742
         {
743 743
             $element = strtolower($matches[1]);
744 744
 
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
                     return;
774 774
                 }
775 775
 
776
-                if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
776
+                if (preg_match('/<\/' . $matches[1] . '>[ ]*$/i', $remainder))
777 777
                 {
778 778
                     $Block['closed'] = true;
779 779
                 }
@@ -790,16 +790,16 @@  discard block
 block discarded – undo
790 790
             return;
791 791
         }
792 792
 
793
-        if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
793
+        if (preg_match('/^<' . $Block['name'] . '(?:[ ]*' . $this->regexHtmlAttribute . ')*[ ]*>/i', $Line['text'])) # open
794 794
         {
795
-            $Block['depth'] ++;
795
+            $Block['depth']++;
796 796
         }
797 797
 
798
-        if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
798
+        if (preg_match('/(.*?)<\/' . $Block['name'] . '>[ ]*$/i', $Line['text'], $matches)) # close
799 799
         {
800 800
             if ($Block['depth'] > 0)
801 801
             {
802
-                $Block['depth'] --;
802
+                $Block['depth']--;
803 803
             }
804 804
             else
805 805
             {
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
             unset($Block['interrupted']);
815 815
         }
816 816
 
817
-        $Block['markup'] .= "\n".$Line['body'];
817
+        $Block['markup'] .= "\n" . $Line['body'];
818 818
 
819 819
         return $Block;
820 820
     }
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 
854 854
     protected function blockTable($Line, array $Block = null)
855 855
     {
856
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
856
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
857 857
         {
858 858
             return;
859 859
         }
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
                     $alignment = $alignment === 'left' ? 'center' : 'right';
891 891
                 }
892 892
 
893
-                $alignments []= $alignment;
893
+                $alignments [] = $alignment;
894 894
             }
895 895
 
896 896
             # ~
@@ -919,11 +919,11 @@  discard block
 block discarded – undo
919 919
                     $alignment = $alignments[$index];
920 920
 
921 921
                     $HeaderElement['attributes'] = array(
922
-                        'style' => 'text-align: '.$alignment.';',
922
+                        'style' => 'text-align: ' . $alignment . ';',
923 923
                     );
924 924
                 }
925 925
 
926
-                $HeaderElements []= $HeaderElement;
926
+                $HeaderElements [] = $HeaderElement;
927 927
             }
928 928
 
929 929
             # ~
@@ -937,18 +937,18 @@  discard block
 block discarded – undo
937 937
                 ),
938 938
             );
939 939
 
940
-            $Block['element']['text'] []= array(
940
+            $Block['element']['text'] [] = array(
941 941
                 'name' => 'thead',
942 942
                 'handler' => 'elements',
943 943
             );
944 944
 
945
-            $Block['element']['text'] []= array(
945
+            $Block['element']['text'] [] = array(
946 946
                 'name' => 'tbody',
947 947
                 'handler' => 'elements',
948 948
                 'text' => array(),
949 949
             );
950 950
 
951
-            $Block['element']['text'][0]['text'] []= array(
951
+            $Block['element']['text'][0]['text'] [] = array(
952 952
                 'name' => 'tr',
953 953
                 'handler' => 'elements',
954 954
                 'text' => $HeaderElements,
@@ -989,11 +989,11 @@  discard block
 block discarded – undo
989 989
                 if (isset($Block['alignments'][$index]))
990 990
                 {
991 991
                     $Element['attributes'] = array(
992
-                        'style' => 'text-align: '.$Block['alignments'][$index].';',
992
+                        'style' => 'text-align: ' . $Block['alignments'][$index] . ';',
993 993
                     );
994 994
                 }
995 995
 
996
-                $Elements []= $Element;
996
+                $Elements [] = $Element;
997 997
             }
998 998
 
999 999
             $Element = array(
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
                 'text' => $Elements,
1003 1003
             );
1004 1004
 
1005
-            $Block['element']['text'][1]['text'] []= $Element;
1005
+            $Block['element']['text'][1]['text'] [] = $Element;
1006 1006
 
1007 1007
             return $Block;
1008 1008
         }
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
     # ~
1053 1053
     #
1054 1054
 
1055
-    public function line($text, $nonNestables=array())
1055
+    public function line($text, $nonNestables = array())
1056 1056
     {
1057 1057
         $markup = '';
1058 1058
 
@@ -1070,14 +1070,14 @@  discard block
 block discarded – undo
1070 1070
             {
1071 1071
                 # check to see if the current inline type is nestable in the current context
1072 1072
 
1073
-                if ( ! empty($nonNestables) and in_array($inlineType, $nonNestables))
1073
+                if (!empty($nonNestables) and in_array($inlineType, $nonNestables))
1074 1074
                 {
1075 1075
                     continue;
1076 1076
                 }
1077 1077
 
1078
-                $Inline = $this->{'inline'.$inlineType}($Excerpt);
1078
+                $Inline = $this->{'inline' . $inlineType}($Excerpt);
1079 1079
 
1080
-                if ( ! isset($Inline))
1080
+                if (!isset($Inline))
1081 1081
                 {
1082 1082
                     continue;
1083 1083
                 }
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 
1092 1092
                 # sets a default inline position
1093 1093
 
1094
-                if ( ! isset($Inline['position']))
1094
+                if (!isset($Inline['position']))
1095 1095
                 {
1096 1096
                     $Inline['position'] = $markerPosition;
1097 1097
                 }
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
     {
1141 1141
         $marker = $Excerpt['text'][0];
1142 1142
 
1143
-        if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/s', $Excerpt['text'], $matches))
1143
+        if (preg_match('/^(' . $marker . '+)[ ]*(.+?)[ ]*(?<!' . $marker . ')\1(?!' . $marker . ')/s', $Excerpt['text'], $matches))
1144 1144
         {
1145 1145
             $text = $matches[2];
1146 1146
             $text = preg_replace("/[ ]*\n/", ' ', $text);
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
         {
1162 1162
             $url = $matches[1];
1163 1163
 
1164
-            if ( ! isset($matches[2]))
1164
+            if (!isset($matches[2]))
1165 1165
             {
1166 1166
                 $url = 'mailto:' . $url;
1167 1167
             }
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 
1182 1182
     protected function inlineEmphasis($Excerpt)
1183 1183
     {
1184
-        if ( ! isset($Excerpt['text'][1]))
1184
+        if (!isset($Excerpt['text'][1]))
1185 1185
         {
1186 1186
             return;
1187 1187
         }
@@ -1224,12 +1224,12 @@  discard block
 block discarded – undo
1224 1224
 
1225 1225
     protected function inlineImage($Excerpt)
1226 1226
     {
1227
-        if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1227
+        if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1228 1228
         {
1229 1229
             return;
1230 1230
         }
1231 1231
 
1232
-        $Excerpt['text']= substr($Excerpt['text'], 1);
1232
+        $Excerpt['text'] = substr($Excerpt['text'], 1);
1233 1233
 
1234 1234
         $Link = $this->inlineLink($Excerpt);
1235 1235
 
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
                 $definition = strtolower($Element['text']);
1312 1312
             }
1313 1313
 
1314
-            if ( ! isset($this->DefinitionData['Reference'][$definition]))
1314
+            if (!isset($this->DefinitionData['Reference'][$definition]))
1315 1315
             {
1316 1316
                 return;
1317 1317
             }
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
             );
1352 1352
         }
1353 1353
 
1354
-        if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
1354
+        if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*' . $this->regexHtmlAttribute . ')*[ ]*\/?>/s', $Excerpt['text'], $matches))
1355 1355
         {
1356 1356
             return array(
1357 1357
                 'markup' => $matches[0],
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 
1363 1363
     protected function inlineSpecialCharacter($Excerpt)
1364 1364
     {
1365
-        if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1365
+        if ($Excerpt['text'][0] === '&' and !preg_match('/^&#?\w+;/', $Excerpt['text']))
1366 1366
         {
1367 1367
             return array(
1368 1368
                 'markup' => '&amp;',
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
         if (isset($SpecialCharacter[$Excerpt['text'][0]]))
1376 1376
         {
1377 1377
             return array(
1378
-                'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
1378
+                'markup' => '&' . $SpecialCharacter[$Excerpt['text'][0]] . ';',
1379 1379
                 'extent' => 1,
1380 1380
             );
1381 1381
         }
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 
1384 1384
     protected function inlineStrikethrough($Excerpt)
1385 1385
     {
1386
-        if ( ! isset($Excerpt['text'][1]))
1386
+        if (!isset($Excerpt['text'][1]))
1387 1387
         {
1388 1388
             return;
1389 1389
         }
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 
1404 1404
     protected function inlineUrl($Excerpt)
1405 1405
     {
1406
-        if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1406
+        if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1407 1407
         {
1408 1408
             return;
1409 1409
         }
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
             $Element = $this->sanitiseElement($Element);
1476 1476
         }
1477 1477
 
1478
-        $markup = '<'.$Element['name'];
1478
+        $markup = '<' . $Element['name'];
1479 1479
 
1480 1480
         if (isset($Element['attributes']))
1481 1481
         {
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
                     continue;
1487 1487
                 }
1488 1488
 
1489
-                $markup .= ' '.$name.'="'.self::escape($value).'"';
1489
+                $markup .= ' ' . $name . '="' . self::escape($value) . '"';
1490 1490
             }
1491 1491
         }
1492 1492
 
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
                 $markup .= self::escape($Element['text'], true);
1509 1509
             }
1510 1510
 
1511
-            $markup .= '</'.$Element['name'].'>';
1511
+            $markup .= '</' . $Element['name'] . '>';
1512 1512
         }
1513 1513
         else
1514 1514
         {
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
 
1541 1541
         $trimmedMarkup = trim($markup);
1542 1542
 
1543
-        if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1543
+        if (!in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1544 1544
         {
1545 1545
             $markup = $trimmedMarkup;
1546 1546
             $markup = substr($markup, 3);
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
     protected function sanitiseElement(array $Element)
1568 1568
     {
1569 1569
         static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/';
1570
-        static $safeUrlNameToAtt  = array(
1570
+        static $safeUrlNameToAtt = array(
1571 1571
             'a'   => 'href',
1572 1572
             'img' => 'src',
1573 1573
         );
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
             $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]);
1578 1578
         }
1579 1579
 
1580
-        if ( ! empty($Element['attributes']))
1580
+        if (!empty($Element['attributes']))
1581 1581
         {
1582 1582
             foreach ($Element['attributes'] as $att => $val)
1583 1583
             {
1584 1584
                 # filter out badly parsed attribute
1585
-                if ( ! preg_match($goodAttribute, $att))
1585
+                if (!preg_match($goodAttribute, $att))
1586 1586
                 {
1587 1587
                     unset($Element['attributes'][$att]);
1588 1588
                 }
@@ -1683,8 +1683,8 @@  discard block
 block discarded – undo
1683 1683
     protected $textLevelElements = array(
1684 1684
         'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1685 1685
         'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1686
-        'i', 'rp', 'del', 'code',          'strike', 'marquee',
1687
-        'q', 'rt', 'ins', 'font',          'strong',
1686
+        'i', 'rp', 'del', 'code', 'strike', 'marquee',
1687
+        'q', 'rt', 'ins', 'font', 'strong',
1688 1688
         's', 'tt', 'kbd', 'mark',
1689 1689
         'u', 'xm', 'sub', 'nobr',
1690 1690
                    'sup', 'ruby',
Please login to merge, or discard this patch.
Braces   +19 added lines, -28 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@  discard block
 block discarded – undo
213 213
                     $CurrentBlock = $Block;
214 214
 
215 215
                     continue;
216
-                }
217
-                else
216
+                } else
218 217
                 {
219 218
                     if ($this->isBlockCompletable($CurrentBlock['type']))
220 219
                     {
@@ -273,8 +272,7 @@  discard block
 block discarded – undo
273 272
             if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
274 273
             {
275 274
                 $CurrentBlock['element']['text'] .= "\n".$text;
276
-            }
277
-            else
275
+            } else
278 276
             {
279 277
                 $Blocks []= $CurrentBlock;
280 278
 
@@ -765,8 +763,7 @@  discard block
 block discarded – undo
765 763
 
766 764
                     $Block['void'] = true;
767 765
                 }
768
-            }
769
-            else
766
+            } else
770 767
             {
771 768
                 if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
772 769
                 {
@@ -790,18 +787,21 @@  discard block
 block discarded – undo
790 787
             return;
791 788
         }
792 789
 
793
-        if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
790
+        if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) {
791
+            # open
794 792
         {
795 793
             $Block['depth'] ++;
796 794
         }
795
+        }
797 796
 
798
-        if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
797
+        if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) {
798
+            # close
799 799
         {
800 800
             if ($Block['depth'] > 0)
801 801
             {
802 802
                 $Block['depth'] --;
803
-            }
804
-            else
803
+        }
804
+            } else
805 805
             {
806 806
                 $Block['closed'] = true;
807 807
             }
@@ -1191,12 +1191,10 @@  discard block
 block discarded – undo
1191 1191
         if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
1192 1192
         {
1193 1193
             $emphasis = 'strong';
1194
-        }
1195
-        elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1194
+        } elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1196 1195
         {
1197 1196
             $emphasis = 'em';
1198
-        }
1199
-        else
1197
+        } else
1200 1198
         {
1201 1199
             return;
1202 1200
         }
@@ -1280,8 +1278,7 @@  discard block
 block discarded – undo
1280 1278
             $extent += strlen($matches[0]);
1281 1279
 
1282 1280
             $remainder = substr($remainder, $extent);
1283
-        }
1284
-        else
1281
+        } else
1285 1282
         {
1286 1283
             return;
1287 1284
         }
@@ -1296,8 +1293,7 @@  discard block
 block discarded – undo
1296 1293
             }
1297 1294
 
1298 1295
             $extent += strlen($matches[0]);
1299
-        }
1300
-        else
1296
+        } else
1301 1297
         {
1302 1298
             if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
1303 1299
             {
@@ -1305,8 +1301,7 @@  discard block
 block discarded – undo
1305 1301
                 $definition = strtolower($definition);
1306 1302
 
1307 1303
                 $extent += strlen($matches[0]);
1308
-            }
1309
-            else
1304
+            } else
1310 1305
             {
1311 1306
                 $definition = strtolower($Element['text']);
1312 1307
             }
@@ -1454,8 +1449,7 @@  discard block
 block discarded – undo
1454 1449
         if ($this->breaksEnabled)
1455 1450
         {
1456 1451
             $text = preg_replace('/[ ]*\n/', "<br />\n", $text);
1457
-        }
1458
-        else
1452
+        } else
1459 1453
         {
1460 1454
             $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
1461 1455
             $text = str_replace(" \n", "\n", $text);
@@ -1502,15 +1496,13 @@  discard block
 block discarded – undo
1502 1496
             if (isset($Element['handler']))
1503 1497
             {
1504 1498
                 $markup .= $this->{$Element['handler']}($Element['text'], $Element['nonNestables']);
1505
-            }
1506
-            else
1499
+            } else
1507 1500
             {
1508 1501
                 $markup .= self::escape($Element['text'], true);
1509 1502
             }
1510 1503
 
1511 1504
             $markup .= '</'.$Element['name'].'>';
1512
-        }
1513
-        else
1505
+        } else
1514 1506
         {
1515 1507
             $markup .= ' />';
1516 1508
         }
@@ -1628,8 +1620,7 @@  discard block
 block discarded – undo
1628 1620
         if ($len > strlen($string))
1629 1621
         {
1630 1622
             return false;
1631
-        }
1632
-        else
1623
+        } else
1633 1624
         {
1634 1625
             return strtolower(substr($string, 0, $len)) === strtolower($needle);
1635 1626
         }
Please login to merge, or discard this patch.
plugins/advancedpagetypes/classes/markdownpage.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -27,56 +27,56 @@
 block discarded – undo
27 27
 
28 28
 class Plugin_AdvancedPageTypes_MarkdownPage extends PageType {
29 29
 
30
-	//https://commonmark.thephpleague.com/
30
+    //https://commonmark.thephpleague.com/
31 31
 
32
-	//https://caret.io/
32
+    //https://caret.io/
33 33
 
34
-	//http://parsedown.org/
34
+    //http://parsedown.org/
35 35
 
36
-	//https://github.com/erusev/parsedown-extra
36
+    //https://github.com/erusev/parsedown-extra
37 37
 
38
-	//https://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php
38
+    //https://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php
39 39
 
40
-	//https://github.com/erusev/parsedown/wiki/Tutorial:-Get-Started
40
+    //https://github.com/erusev/parsedown/wiki/Tutorial:-Get-Started
41 41
 
42
-	public function getContent(): string {
43
-		$content = "";
42
+    public function getContent(): string {
43
+        $content = "";
44 44
 
45
-		//check, if generated html is already cached
46
-		if (Cache::contains("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias())) {
47
-			$content = Cache::get("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias());
48
-		} else {
49
-			//require parsedown
50
-			require_once(PLUGIN_PATH . "advancedpagetypes/parsedown-1.7.1/Parsedown.php");
45
+        //check, if generated html is already cached
46
+        if (Cache::contains("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias())) {
47
+            $content = Cache::get("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias());
48
+        } else {
49
+            //require parsedown
50
+            require_once(PLUGIN_PATH . "advancedpagetypes/parsedown-1.7.1/Parsedown.php");
51 51
 
52
-			$parsedown = Parsedown::instance();
52
+            $parsedown = Parsedown::instance();
53 53
 
54
-			//enables automatic line breaks
55
-			$parsedown->setBreaksEnabled(true);
54
+            //enables automatic line breaks
55
+            $parsedown->setBreaksEnabled(true);
56 56
 
57
-			//escape html
58
-			$parsedown->setMarkupEscaped(true);
57
+            //escape html
58
+            $parsedown->setMarkupEscaped(true);
59 59
 
60
-			//automatically link urls
61
-			$parsedown->setUrlsLinked(true);
60
+            //automatically link urls
61
+            $parsedown->setUrlsLinked(true);
62 62
 
63
-			//enable safe mode
64
-			$parsedown->setSafeMode(true);
63
+            //enable safe mode
64
+            $parsedown->setSafeMode(true);
65 65
 
66
-			$content = $parsedown->text($this->getPage()->getContent());
66
+            $content = $parsedown->text($this->getPage()->getContent());
67 67
 
68
-			//cache content
69
-			Cache::put("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias(), $content);
70
-		}
68
+            //cache content
69
+            Cache::put("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias(), $content);
70
+        }
71 71
 
72
-		Events::throwEvent("plugin_markdownpage_parse", array(
73
-			'content' => &$content,
74
-			'page' => &$this->getPage(),
75
-			'page_type' => &$this
76
-		));
72
+        Events::throwEvent("plugin_markdownpage_parse", array(
73
+            'content' => &$content,
74
+            'page' => &$this->getPage(),
75
+            'page_type' => &$this
76
+        ));
77 77
 
78
-		return $content;
79
-	}
78
+        return $content;
79
+    }
80 80
 
81 81
 }
82 82
 
Please login to merge, or discard this patch.