<?php

    /**
     *
     * @extension       TMarlev Calculator
     * @author          Lev Milicenco<support@marlev.it>
     * @link            http://www.marlev.it
     * @copyright       Copyright 2014 marlev.it All Rights Reserved
     * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
     */
    defined('_JEXEC') or die;

    class Tmarlevv2Controller extends JControllerLegacy {

        public function display($cachable = false, $urlparams = false) {

            JRequest::setVar('view', JRequest::getCmd('view', 'tmarlevv2'));
            $id = JRequest::getInt("id");
            $install = JRequest::getVar("install");
            if ($install == "true" && $id > 0) {
                $session = JFactory::getSession();

                $sessionQueue = $session->get('application.queue');
                if (isset($sessionQueue)) {
                    foreach ($sessionQueue as $ar) {
                        if ((strpos($ar["message"], 'Template successfully updated') !== false) || (strpos($ar["message"], 'Template successfully installed') !== false) || (strpos($ar["message"], 'Please contact Marlev Support') !== false)) {
                            $sessionQueue = $session->clear('application.queue');
                            JFactory::getApplication()->enqueueMessage($ar["message"], 'message');
                        }
                    }
                }
            }
            parent::display($cachable);
        }

    }

?>
