| Current Path : /home/jeromecohp/www/administrator/components/com_emailbeautifier/models/ |
| Current File : /home/jeromecohp/www/administrator/components/com_emailbeautifier/models/cp.php |
<?php
/**
* @package EmailBeautifier
* @subpackage com_emailbeautifier
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// No direct access.
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Application\ApplicationHelper;
jimport('joomla.application.component.model');
jimport('joomla.filesystem.file');
/**
* Model CP
*
* @package Com_EmailBeautifier
*
* @subpackage site
*
* @since 1.6
*/
class EmailbeautifierModelCp extends BaseDatabaseModel
{
protected $downloadid;
protected $extensionsDetails;
/**
* Constructor
*
* @since 2.2
*/
public function __construct()
{
// Get download id
$params = ComponentHelper::getParams('com_emailbeautifier');
$this->downloadid = $params->get('downloadid');
// EB
$this->extensionsDetails = new stdClass;
$this->extensionsDetails->extension = 'com_emailbeautifier';
$this->extensionsDetails->extensionElement = 'com_emailbeautifier';
$this->extensionsDetails->extensionType = 'component';
$this->extensionsDetails->updateStreamName = 'Email Beautifier';
$this->extensionsDetails->updateStreamType = 'extension';
$this->extensionsDetails->updateStreamUrl = 'https://techjoomla.com/updates/stream/emailbeautifier.xml?format=xml';
$this->extensionsDetails->downloadidParam = 'downloadid';
// Call the parents constructor
parent::__construct();
}
/**
* This function returns the plugin names under the email-alerts component
*
* @return null.
*
* @since 2.2
*/
public function getPluginNames()
{
// FIRST GET THE EMAIL-ALERTS RELATED PLUGINS FRM THE `jos_plugins` TABLE
$this->_db->setQuery('SELECT element FROM #__extensions WHERE folder = \'emailalerts\' AND enabled = 1');
// Get the plugin names and store in an array
$email_alert_plugins_array = $this->_db->loadColumn();
return $email_alert_plugins_array;
}
/**
* Function to return description of the 'emailalert' plugins from the XML file
* Input: plugin_array which contains names of the 'emailalert' plugins
* This function is called only from the view.html.php file
*
* @param string $plugin_array plugin array.
*
* @return null.
*
* @since 2.2
*/
public function getPluginDescriptionFromXML($plugin_array)
{
$plugin_description_array = array();
// Set array index to 0
$i = 0;
if ($plugin_array)
{
foreach ($plugin_array as $emailalert_plugin)
{
// Get the description of the plugin from the XML file
$file = JPATH_SITE . '/plugins/emailalerts' . $emailalert_plugin . '/' . $emailalert_plugin . '.xml';
$data = ApplicationHelper::parseXMLInstallFile($file);
// Store it in the array
$plugin_description_array[$i++] = $data['description'];
}
}
return $plugin_description_array;
}
/**
* Refreshes the Joomla! update sites for this extension as needed
*
* @return void
*
* @since 2.2.0
*/
public function refreshUpdateSite()
{
// Trigger plugin
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('system', 'tjupdates');
$dispatcher->trigger('refreshUpdateSite', array($this->extensionsDetails));
}
/**
* Get latest version fetched by joomla updater
*
* @return mixed boolean or array
*
* @since 2.2.0
*/
public function getLatestVersion()
{
// Trigger plugin
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('system', 'tjupdates');
$latestVersion = $dispatcher->trigger('getLatestVersion', array($this->extensionsDetails));
return (isset($latestVersion[0]) ? $latestVersion[0] : false);
}
}