Completed
Pull Request — master (#285)
by Frank
11:57
created
plugins/phile/errorHandler/config.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * the configuration file
4
- */
3
+     * the configuration file
4
+     */
5 5
 
6 6
 return array(
7
-	'handler' 			=> \Phile\Plugin\Phile\ErrorHandler\Plugin::HANDLER_ERROR_LOG
7
+    'handler' 			=> \Phile\Plugin\Phile\ErrorHandler\Plugin::HANDLER_ERROR_LOG
8 8
 );
Please login to merge, or discard this patch.
plugins/phile/parserMeta/Classes/Plugin.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin class
4
- */
3
+     * Plugin class
4
+     */
5 5
 namespace Phile\Plugin\Phile\ParserMeta;
6 6
 
7 7
 use Phile\Core\ServiceLocator;
@@ -19,18 +19,18 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Plugin extends AbstractPlugin {
21 21
 
22
-	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
22
+    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
23 23
 
24
-	/**
25
-	 * onPluginsLoaded method
26
-	 *
27
-	 * @param null   $data
28
-	 *
29
-	 * @return mixed|void
30
-	 */
31
-	public function onPluginsLoaded($data = null) {
32
-		ServiceLocator::registerService('Phile_Parser_Meta',
33
-			new Meta($this->settings));
34
-	}
24
+    /**
25
+     * onPluginsLoaded method
26
+     *
27
+     * @param null   $data
28
+     *
29
+     * @return mixed|void
30
+     */
31
+    public function onPluginsLoaded($data = null) {
32
+        ServiceLocator::registerService('Phile_Parser_Meta',
33
+            new Meta($this->settings));
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
plugins/phile/parserMeta/Classes/Parser/Meta.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -16,97 +16,97 @@
 block discarded – undo
16 16
  * @package Phile\Plugin\Phile\ParserMeta\Parser
17 17
  */
18 18
 class Meta implements MetaInterface {
19
-	/** @var array $config the configuration for this parser */
20
-	private $config;
19
+    /** @var array $config the configuration for this parser */
20
+    private $config;
21 21
 
22
-	/**
23
-	 * the constructor
24
-	 *
25
-	 * @param array $config
26
-	 */
27
-	public function __construct(array $config = null) {
28
-		if (!is_null($config)) {
29
-			$this->config = $config;
30
-		}
31
-	}
22
+    /**
23
+     * the constructor
24
+     *
25
+     * @param array $config
26
+     */
27
+    public function __construct(array $config = null) {
28
+        if (!is_null($config)) {
29
+            $this->config = $config;
30
+        }
31
+    }
32 32
 
33
-	/**
34
-	 * parse the content and extract meta information
35
-	 *
36
-	 * @param string $rawData raw page data
37
-	 * @return array with key/value store
38
-	 */
39
-	public function parse($rawData) {
40
-		$rawData = trim($rawData);
33
+    /**
34
+     * parse the content and extract meta information
35
+     *
36
+     * @param string $rawData raw page data
37
+     * @return array with key/value store
38
+     */
39
+    public function parse($rawData) {
40
+        $rawData = trim($rawData);
41 41
 
42
-		$start = substr($rawData, 0, 4);
43
-		if ($start === '<!--') {
44
-			$stop = '-->';
45
-		} elseif (substr($start, 0, 2) === '/*') {
46
-			$start = '/*';
47
-			$stop = '*/';
48
-		} else {
49
-			return [];
50
-		}
42
+        $start = substr($rawData, 0, 4);
43
+        if ($start === '<!--') {
44
+            $stop = '-->';
45
+        } elseif (substr($start, 0, 2) === '/*') {
46
+            $start = '/*';
47
+            $stop = '*/';
48
+        } else {
49
+            return [];
50
+        }
51 51
 
52
-		$meta = trim(substr($rawData, strlen($start), strpos($rawData, $stop) - (strlen($stop) + 1)));
53
-		if (strtolower($this->config['format']) === 'yaml') {
54
-			$meta = Yaml::parse($meta);
55
-		} else {
56
-			$meta = $this->parsePhileFormat($meta);
57
-		}
58
-		$meta = ($meta === null) ? [] : $this->convertKeys($meta);
59
-		return $meta;
60
-	}
52
+        $meta = trim(substr($rawData, strlen($start), strpos($rawData, $stop) - (strlen($stop) + 1)));
53
+        if (strtolower($this->config['format']) === 'yaml') {
54
+            $meta = Yaml::parse($meta);
55
+        } else {
56
+            $meta = $this->parsePhileFormat($meta);
57
+        }
58
+        $meta = ($meta === null) ? [] : $this->convertKeys($meta);
59
+        return $meta;
60
+    }
61 61
 
62
-	/**
63
-	 * convert meta data keys
64
-	 *
65
-	 * Creates "compatible" keys allowing easy access e.g. as template var.
66
-	 *
67
-	 * Conversions applied:
68
-	 *
69
-	 * - lowercase all chars
70
-	 * - replace special chars and whitespace with underscore
71
-	 *
72
-	 * @param array $meta meta-data
73
-	 * @return array
74
-	 */
75
-	protected function convertKeys(array $meta) {
76
-		$return = [];
77
-		foreach ($meta as $key => $value) {
78
-			if (is_array($value)) {
79
-				$value = $this->convertKeys($value);
80
-			}
81
-			$newKey = strtolower($key);
82
-			$newKey = preg_replace('/[^\w+]/', '_', $newKey);
83
-			$return[$newKey] = $value;
84
-		}
85
-		return $return;
86
-	}
62
+    /**
63
+     * convert meta data keys
64
+     *
65
+     * Creates "compatible" keys allowing easy access e.g. as template var.
66
+     *
67
+     * Conversions applied:
68
+     *
69
+     * - lowercase all chars
70
+     * - replace special chars and whitespace with underscore
71
+     *
72
+     * @param array $meta meta-data
73
+     * @return array
74
+     */
75
+    protected function convertKeys(array $meta) {
76
+        $return = [];
77
+        foreach ($meta as $key => $value) {
78
+            if (is_array($value)) {
79
+                $value = $this->convertKeys($value);
80
+            }
81
+            $newKey = strtolower($key);
82
+            $newKey = preg_replace('/[^\w+]/', '_', $newKey);
83
+            $return[$newKey] = $value;
84
+        }
85
+        return $return;
86
+    }
87 87
 
88
-	/**
89
-	 * Phile meta format parser.
90
-	 *
91
-	 * @param string $string unparsed meta-data
92
-	 * @return array|null array with meta-tags; null: on meta-data found
93
-	 *
94
-	 * @deprecated since 1.6.0 Phile is going to switch to YAML
95
-	 */
96
-	protected function parsePhileFormat($string) {
97
-		if (empty($string)) {
98
-			return null;
99
-		}
100
-		$meta = [];
101
-		$lines = explode("\n", $string);
102
-		foreach ($lines as $line) {
103
-			$parts = explode(':', $line, 2);
104
-			if (count($parts) !== 2) {
105
-				continue;
106
-			}
107
-			$parts = array_map('trim', $parts);
108
-			$meta[$parts[0]] = $parts[1];
109
-		}
110
-		return $meta;
111
-	}
88
+    /**
89
+     * Phile meta format parser.
90
+     *
91
+     * @param string $string unparsed meta-data
92
+     * @return array|null array with meta-tags; null: on meta-data found
93
+     *
94
+     * @deprecated since 1.6.0 Phile is going to switch to YAML
95
+     */
96
+    protected function parsePhileFormat($string) {
97
+        if (empty($string)) {
98
+            return null;
99
+        }
100
+        $meta = [];
101
+        $lines = explode("\n", $string);
102
+        foreach ($lines as $line) {
103
+            $parts = explode(':', $line, 2);
104
+            if (count($parts) !== 2) {
105
+                continue;
106
+            }
107
+            $parts = array_map('trim', $parts);
108
+            $meta[$parts[0]] = $parts[1];
109
+        }
110
+        return $meta;
111
+    }
112 112
 }
Please login to merge, or discard this patch.
plugins/phile/parserMarkdown/Classes/Plugin.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin class
4
- */
3
+     * Plugin class
4
+     */
5 5
 namespace Phile\Plugin\Phile\ParserMarkdown;
6 6
 
7 7
 use Phile\Core\ServiceLocator;
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Plugin extends AbstractPlugin {
21 21
 
22
-	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
22
+    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
23 23
 
24
-	/**
25
-	 * onPluginsLoaded method
26
-	 *
27
-	 * @param null   $data
28
-	 *
29
-	 * @return mixed|void
30
-	 */
31
-	public function onPluginsLoaded($data = null) {
32
-		ServiceLocator::registerService('Phile_Parser', new Markdown($this->settings));
33
-	}
24
+    /**
25
+     * onPluginsLoaded method
26
+     *
27
+     * @param null   $data
28
+     *
29
+     * @return mixed|void
30
+     */
31
+    public function onPluginsLoaded($data = null) {
32
+        ServiceLocator::registerService('Phile_Parser', new Markdown($this->settings));
33
+    }
34 34
 }
Please login to merge, or discard this patch.
plugins/phile/parserMarkdown/Classes/Parser/Markdown.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The Mardown parser class
4
- */
3
+     * The Mardown parser class
4
+     */
5 5
 namespace Phile\Plugin\Phile\ParserMarkdown\Parser;
6 6
 
7 7
 use Michelf\MarkdownExtra;
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
  * @package Phile\Plugin\Phile\ParserMarkdown\Parser
17 17
  */
18 18
 class Markdown implements ParserInterface {
19
-	/** @var mixed the configuration */
20
-	private $config;
19
+    /** @var mixed the configuration */
20
+    private $config;
21 21
 
22
-	/**
23
-	 * the constructor
24
-	 *
25
-	 * @param null $config
26
-	 */
27
-	public function __construct($config = null) {
28
-		if (!is_null($config)) {
29
-			$this->config = $config;
30
-		}
31
-	}
22
+    /**
23
+     * the constructor
24
+     *
25
+     * @param null $config
26
+     */
27
+    public function __construct($config = null) {
28
+        if (!is_null($config)) {
29
+            $this->config = $config;
30
+        }
31
+    }
32 32
 
33
-	/**
34
-	 * overload parse with the MarkdownExtra parser
35
-	 *
36
-	 * @param $data
37
-	 *
38
-	 * @return string
39
-	 */
40
-	public function parse($data) {
41
-		$parser = new MarkdownExtra;
42
-		foreach ($this->config as $key => $value) {
43
-			$parser->{$key} = $value;
44
-		}
33
+    /**
34
+     * overload parse with the MarkdownExtra parser
35
+     *
36
+     * @param $data
37
+     *
38
+     * @return string
39
+     */
40
+    public function parse($data) {
41
+        $parser = new MarkdownExtra;
42
+        foreach ($this->config as $key => $value) {
43
+            $parser->{$key} = $value;
44
+        }
45 45
 
46
-		return $parser->transform($data);
47
-	}
46
+        return $parser->transform($data);
47
+    }
48 48
 }
Please login to merge, or discard this patch.
plugins/phile/parserMarkdown/config.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * the configuration file
4
- *
5
- * @see https://michelf.ca/projects/php-markdown/configuration/
6
- */
3
+     * the configuration file
4
+     *
5
+     * @see https://michelf.ca/projects/php-markdown/configuration/
6
+     */
7 7
 
8 8
 return array(
9
-	'empty_element_suffix' => ' />',
10
-	'tab_width'            => 4,
11
-	'no_markup'            => false,
12
-	'no_entities'          => false,
13
-	'predef_urls'          => array(
14
-		'base_url' => \Phile\Core\Utility::getBaseUrl() // base_url is a good reference to have
15
-	),
16
-	'predef_titles'        => array(),
17
-	'fn_id_prefix'         => "",
18
-	'fn_link_title'        => "",
19
-	'fn_backlink_title'    => "",
20
-	'fn_link_class'        => "footnote-ref",
21
-	'fn_backlink_class'    => "footnote-backref",
22
-	'code_class_prefix'    => "",
23
-	'code_attr_on_pre'     => false,
24
-	'predef_abbr'          => array()
9
+    'empty_element_suffix' => ' />',
10
+    'tab_width'            => 4,
11
+    'no_markup'            => false,
12
+    'no_entities'          => false,
13
+    'predef_urls'          => array(
14
+        'base_url' => \Phile\Core\Utility::getBaseUrl() // base_url is a good reference to have
15
+    ),
16
+    'predef_titles'        => array(),
17
+    'fn_id_prefix'         => "",
18
+    'fn_link_title'        => "",
19
+    'fn_backlink_title'    => "",
20
+    'fn_link_class'        => "footnote-ref",
21
+    'fn_backlink_class'    => "footnote-backref",
22
+    'code_class_prefix'    => "",
23
+    'code_attr_on_pre'     => false,
24
+    'predef_abbr'          => array()
25 25
 );
Please login to merge, or discard this patch.
plugins/mycompany/demoPlugin/Classes/Plugin.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin class
4
- */
3
+     * Plugin class
4
+     */
5 5
 
6 6
 /*
7 7
  * The namespace structure is Phile\Plugin\<vendor>\<plugin-name>
@@ -28,37 +28,37 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class Plugin extends \Phile\Plugin\AbstractPlugin {
30 30
 
31
-	/**
32
-	 * subscribe to Phile events with methods of this class
33
-	 *
34
-	 * In this example we subscribe to "before_parse_content" and
35
-	 * "outputPluginSettings" will be called.
36
-	 */
37
-	protected $events = ['before_parse_content' => 'outputPluginSettings'];
31
+    /**
32
+     * subscribe to Phile events with methods of this class
33
+     *
34
+     * In this example we subscribe to "before_parse_content" and
35
+     * "outputPluginSettings" will be called.
36
+     */
37
+    protected $events = ['before_parse_content' => 'outputPluginSettings'];
38 38
 
39
-	/**
40
-	 * the method we assigned to the 'before_parse_content' event
41
-	 *
42
-	 * in this example we output this plugins' settings on the top of every page
43
-	 *
44
-	 * @param null|array $data depends on the particular event (see Phile's event docs)
45
-	 */
46
-	public function outputPluginSettings($data = null) {
47
-		// you can access this plugins' config in $this->settings
48
-		$settings = $this->settings;
39
+    /**
40
+     * the method we assigned to the 'before_parse_content' event
41
+     *
42
+     * in this example we output this plugins' settings on the top of every page
43
+     *
44
+     * @param null|array $data depends on the particular event (see Phile's event docs)
45
+     */
46
+    public function outputPluginSettings($data = null) {
47
+        // you can access this plugins' config in $this->settings
48
+        $settings = $this->settings;
49 49
 
50
-		$content =  $data['content'];
51
-		$content = $this->printPhpAsMarkdown($settings) . $content;
50
+        $content =  $data['content'];
51
+        $content = $this->printPhpAsMarkdown($settings) . $content;
52 52
 
53
-		$page = $data['page'];
54
-		$page->setContent($content);
55
-	}
53
+        $page = $data['page'];
54
+        $page->setContent($content);
55
+    }
56 56
 
57
-	/**
58
-	 * plugin helper method for printing PHP as markdown code
59
-	 */
60
-	protected function printPhpAsMarkdown($input) {
61
-		return "\n```php\n" . trim(print_r($input, true), "\n") . "\n```\n";
62
-	}
57
+    /**
58
+     * plugin helper method for printing PHP as markdown code
59
+     */
60
+    protected function printPhpAsMarkdown($input) {
61
+        return "\n```php\n" . trim(print_r($input, true), "\n") . "\n```\n";
62
+    }
63 63
 
64 64
 }
Please login to merge, or discard this patch.
plugins/mycompany/demoPlugin/config.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,5 +3,5 @@
 block discarded – undo
3 3
  * config file
4 4
  */
5 5
 return [
6
-	'setting-example' => 'I love Phile!'
6
+    'setting-example' => 'I love Phile!'
7 7
 ];
Please login to merge, or discard this patch.
default_config.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -57,49 +57,49 @@
 block discarded – undo
57 57
  * include core plugins
58 58
  */
59 59
 $config['plugins'] = [
60
-	/**
61
-	 * error handler
62
-	 */
63
-	'phile\\errorHandler' => [
64
-		'active' => true,
65
-		'handler' => \Phile\Plugin\Phile\ErrorHandler\Plugin::HANDLER_DEVELOPMENT
66
-	],
67
-	/**
68
-	 * setup check
69
-	 */
70
-	'phile\\setupCheck' => ['active' => true],
71
-	/**
72
-	 * parser
73
-	 */
74
-	'phile\\parserMarkdown' => ['active' => true],
75
-	/**
76
-	 * meta-tag parser
77
-	 */
78
-	'phile\\parserMeta' => [
79
-		'active' => true,
80
-		/**
81
-		 * Set meta-data format.
82
-		 *
83
-		 * - 'Phile' (default) Phile legacy format
84
-		 * - 'YAML' YAML
85
-		 *
86
-		 * Phile is going to switch to YAML for parsing meta tags. But if you
87
-		 * want to use YAML today you can change the format here.
88
-		 */
89
-		 'format' => 'Phile'
90
-	],
91
-	/**
92
-	 * template engine
93
-	 */
94
-	'phile\\templateTwig' => ['active' => true],
95
-	/**
96
-	 * cache engine
97
-	 */
98
-	'phile\\phpFastCache' => ['active' => true],
99
-	/**
100
-	 * persistent data storage
101
-	 */
102
-	'phile\\simpleFileDataPersistence' => ['active' => true],
60
+    /**
61
+     * error handler
62
+     */
63
+    'phile\\errorHandler' => [
64
+        'active' => true,
65
+        'handler' => \Phile\Plugin\Phile\ErrorHandler\Plugin::HANDLER_DEVELOPMENT
66
+    ],
67
+    /**
68
+     * setup check
69
+     */
70
+    'phile\\setupCheck' => ['active' => true],
71
+    /**
72
+     * parser
73
+     */
74
+    'phile\\parserMarkdown' => ['active' => true],
75
+    /**
76
+     * meta-tag parser
77
+     */
78
+    'phile\\parserMeta' => [
79
+        'active' => true,
80
+        /**
81
+         * Set meta-data format.
82
+         *
83
+         * - 'Phile' (default) Phile legacy format
84
+         * - 'YAML' YAML
85
+         *
86
+         * Phile is going to switch to YAML for parsing meta tags. But if you
87
+         * want to use YAML today you can change the format here.
88
+         */
89
+            'format' => 'Phile'
90
+    ],
91
+    /**
92
+     * template engine
93
+     */
94
+    'phile\\templateTwig' => ['active' => true],
95
+    /**
96
+     * cache engine
97
+     */
98
+    'phile\\phpFastCache' => ['active' => true],
99
+    /**
100
+     * persistent data storage
101
+     */
102
+    'phile\\simpleFileDataPersistence' => ['active' => true],
103 103
 ];
104 104
 
105 105
 return $config;
Please login to merge, or discard this patch.