<?php

/**
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS\module\contentbuilder
 * @copyright Copyright (c) 2016 clearFusionCMS. All rights reserved.
 * @link http://clearfusioncms.com
 */

/**
 * contentbuilderEvents Class
 *
 * Class to process contentbuilder module events.
 *
 * @package clearFusionCMS\module\contentbuilder
 */
class contentbuilderEvents {

	/**
	 * Event handler notified for admin page render.
	 *
	 * @param flEvent $evt The event object.
	 */
	function onBeforeAdminPageRender($evt) {
		/** @var cfTemplateEngine $tpl */
		$tpl = $evt->getParam('templateEngine');
		$tpl->getCodeBuffer()
			->bufferCSS('system/app/ionicons/css/ionicons.min.css')
			->bufferCSS('system/modules/contentbuilder/elements.css');
	}
	/**
	 *
	 * Event handler notified for page render.
	 *
	 * @param flEvent $evt The event object.
	 */
	function onBeforePageRender($evt) {
		$cfg = new flConfigDb('cfContentBuilder', clearFusionCMS::getDb());

		/** @var cfTemplateEngine $tpl */
		$tpl = $evt->getParam('templateEngine');
		$buffer = $tpl->getCodeBuffer();

		if($cfg->get('ionicons', true))
			$buffer->bufferCSS('system/app/ionicons/css/ionicons.min.css');

		if($cfg->get('elemcss', true))
			$buffer->bufferCSS('system/modules/contentbuilder/elements.css');
	}
}
