| 
									
										
										
										
											2015-10-23 12:41:54 -04:00
										 |  |  | <?php namespace Sensory5\Shortcode; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use App; | 
					
						
							|  |  |  | use Str; | 
					
						
							|  |  |  | use Html; | 
					
						
							|  |  |  | use Event; | 
					
						
							|  |  |  | use System\Classes\PluginBase; | 
					
						
							|  |  |  | use Illuminate\Foundation\AliasLoader; | 
					
						
							|  |  |  | use Sensory5\Shortcode\Models\Settings; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Shortcode Plugin Information File | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Plugin extends PluginBase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Returns information about this plugin. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function pluginDetails() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return [ | 
					
						
							|  |  |  |             'name'        => 'Shortcode', | 
					
						
							|  |  |  |             'description' => 'Shortcode integration for OctoberCMS.', | 
					
						
							|  |  |  |             'author'      => 'Sensory 5', | 
					
						
							|  |  |  |             'icon'        => 'icon-code' | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Register service provider, Twig extensions, and alias facade. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function boot() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // Service provider
 | 
					
						
							| 
									
										
										
										
											2015-10-23 15:34:31 -04:00
										 |  |  |         App::register('\Sensory5\Shortcode\Classes\ServiceProvider'); | 
					
						
							| 
									
										
										
										
											2015-10-23 12:41:54 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Register alias
 | 
					
						
							|  |  |  |         $alias = AliasLoader::getInstance(); | 
					
						
							| 
									
										
										
										
											2015-10-23 15:34:31 -04:00
										 |  |  |         $alias->alias('Shortcode', '\Sensory5\Shortcode\Classes\Facade'); | 
					
						
							| 
									
										
										
										
											2015-10-23 12:41:54 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Enable shortcodes on all pages if requested
 | 
					
						
							|  |  |  |         if (Settings::get('enable_on_render', false)) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2015-11-04 17:36:42 -05:00
										 |  |  |             Event::listen('cms.page.postprocess', function($controller, $url, $page, $dataHolder) { | 
					
						
							| 
									
										
										
										
											2015-10-23 12:41:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-04 17:36:42 -05:00
										 |  |  |                 $dataHolder->content = \Shortcode::parse($dataHolder->content); | 
					
						
							| 
									
										
										
										
											2015-10-23 12:41:54 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Register twig filters | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function registerMarkupTags() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return [ | 
					
						
							|  |  |  |             'filters' => [ 'shortcode' => ['\Shortcode', 'parse'] ], | 
					
						
							|  |  |  |             'functions' => ['shortcode' => ['\Shortcode', 'parse'] ] | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Register backend settings | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function registerSettings() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return [ | 
					
						
							|  |  |  |             'settings' => [ | 
					
						
							|  |  |  |                 'label' => 'Shortcode Settings', | 
					
						
							|  |  |  |                 'description' => 'Manage shortcode settings', | 
					
						
							|  |  |  |                 'category' => 'Shortcodes', | 
					
						
							|  |  |  |                 'icon' => 'icon-code', | 
					
						
							|  |  |  |                 'class' => 'Sensory5\Shortcode\Models\Settings', | 
					
						
							|  |  |  |                 'order' => 600, | 
					
						
							|  |  |  |                 'keywords' => 'shortcode shortcodes' | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |