* @copyright Since 2013 Ovidiu Cimpean
* @license Do not edit, modify or copy this file
*
* @version Release: 4
*/
class NewsletterProOurModules
{
public $iso_code;
public $context;
public $module;
public $lang;
public static function newInstance()
{
return new self();
}
public function __construct()
{
$this->context = Context::getContext();
$this->module = NewsletterPro::getInstance();
$this->iso_code = $this->context->language->iso_code;
}
public function get()
{
$this->lang = (empty($this->iso_code)) ? 'en' : $this->iso_code;
$contents = $this->getDeveloperModules();
if ('no_connection' == $contents[0]) {
$links = 'Checkout the links below to see our high quality modules:
';
foreach ($contents[1] as $value) {
$links .= ''.$value.'
';
}
return $links;
}
$xml = simplexml_load_string($contents);
$items = $xml->channel->item;
$count = 0;
foreach ($items as $item) {
if ((int) $item->displayNew) {
++$count;
}
}
$this->context->smarty->assign([
'items' => $items,
'display_version' => (int) $xml->channel->displayVersion,
'display_rating' => (int) $xml->channel->displayRating,
'display_details' => (int) $xml->channel->displayDetails,
'display_video' => (int) $xml->channel->displayVideo,
'display_demo' => (int) $xml->channel->displayDemo,
'display_price' => (int) $xml->channel->displayPrice,
'display_badge' => (int) $xml->channel->displayBadge,
'display_new' => (int) $xml->channel->displayNew,
'count_new' => $count,
]);
$output = $this->context->smarty->fetch(dirname(__FILE__).'/../views/templates/admin/our_modules_content.tpl');
return $output;
}
public function getDeveloperModules()
{
if ('en' != $this->lang && 'fr' != $this->lang && 'es' != $this->lang) {
$this->lang = 'en';
}
$links = [
'http://addons.prestashop.com/'.$this->lang.'/93_proquality',
];
$modules = '';
$count = 0;
foreach ($links as $value) {
$contents = @Tools::file_get_contents($value);
if (empty($contents)) {
return [
'no_connection',
$links,
];
}
preg_match_all('/(