Skip to content

Commit

Permalink
Merge branch 'release/v1.8.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosescri committed Jun 23, 2017
2 parents 5b81b78 + 8936ef9 commit 69ac302
Show file tree
Hide file tree
Showing 54 changed files with 350 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Adminhtml_Log_View extends Mage_Adminhtml_Block_Widget_Grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Doofinder/Feed/Block/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Integration extends Mage_Core_Block_Abstract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Buttons_Generate extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Buttons_ViewLog extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Doofinder/Feed/Block/Settings/Locks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Locks extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* This file is part of Doofinder_Feed.
*/

/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_AtomicUpdates extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$helper = Mage::helper('doofinder_feed');

$this->setElement($element);
$name = $element->getName();
$element->setScopeLabel('');

$messages = array();
foreach (Mage::app()->getStores() as $store) {
if ($store->getIsActive()) {
$engineEnabled = Mage::getStoreConfig('doofinder_search/internal_settings/enable', $store->getCode());
$atomicUpdatesEnabled = Mage::getStoreConfig('doofinder_cron/feed_settings/atomic_updates_enabled', $store->getCode());

if (!$engineEnabled || !$atomicUpdatesEnabled) {
$message = $helper->__('Atomic updates are <strong>disabled</strong>.');
} else {
$message = $helper->__('Atomic updates are <strong>enabled</strong>. Your products will be automatically indexed when they are created, updated or deleted.');
}

$messages[$store->getName()] = $message;
}
}

if (count(array_unique($messages)) == 1) {
return reset($messages);
}

$html = '<ul>';
foreach ($messages as $name => $message) {
$html .= '<li><strong>' . $name . ':</strong><p>' . $message . '</p></li>';
}
$html .= '</ul>';

return $html;
}
}
52 changes: 0 additions & 52 deletions app/code/community/Doofinder/Feed/Block/Settings/Panel/Cron.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_CronDescription extends Doofinder_Feed_Block_Settings_Panel_Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_Datetime extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_Description extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* This file is part of Doofinder_Feed.
*/

/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_DynamicFeedUrl extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$helper = Mage::helper('doofinder_feed');

$this->setElement($element);
$name = $element->getName();
$element->setScopeLabel('');

$html = '<ul>';
foreach (Mage::app()->getStores() as $store) {
if ($store->getIsActive()) {
$password = $store->getConfig('doofinder_cron/feed_settings/password');
$params = array('language' => $store->getCode());

if ($password) {
$params['password'] = $password;
}

$url = Mage::getUrl('doofinder/feed', array('_store' => $store->getCode(), '_nosid' => true) + $params);
$anchor = '<a href="' . $url . '">' . $url . '</a>';
$html .= '<li><strong>' . $store->getName() . ':</strong><p>' . $anchor . '</p></li>';
}
}
$html .= '</ul>';
$html .= '<p>';
$html .= $helper->__('If cron feed doesn\'t work for you, use these URLs to dynamically index your content from Doofinder. Contact support if you need help.');
$html .= '</p>';

return $html;
}
}
89 changes: 71 additions & 18 deletions app/code/community/Doofinder/Feed/Block/Settings/Panel/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand All @@ -17,8 +17,40 @@ class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_Syst
*/
const ERROR_PREFIX = "#error#";

// 12 Hours in seconds
const ALLOWED_TIME = 43200;

protected function getCronMessage()
{
$lastSchedule = Mage::getModel('cron/schedule')->getCollection()
->setOrder('finished_at', 'desc')
->getFirstItem();

$message = '';
if ($lastSchedule && count($lastSchedule->getData()) > 0) {
$scheduleTime = strtotime($lastSchedule->getFinishedAt());
$currentTime = time();

// Difference in seconds
$dif = ($currentTime - $scheduleTime);

// If difference is bigger than allowed, display message
if ($dif > self::ALLOWED_TIME) {

$message = sprintf('Cron was run for the last time at %s. Taking into account the settings of the step delay option, there might be problems with the cron\'s configuration.', $lastSchedule->getFinishedAt());
Mage::helper('doofinder_feed')->__($message);
}
} else {
$message = Mage::helper('doofinder_feed')->__('There are no registered cron tasks. Please, check your system\'s crontab configuration.');
}

return '<p class="error">' . $message . '</p>';
}

protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$helper = Mage::helper('doofinder_feed');

$this->setElement($element);
$name = $element->getName();
$element->setScopeLabel('');
Expand All @@ -36,32 +68,53 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
}
}

$files = array();
$enabled = false;
$messages = array();

foreach ($stores as $store) {
$process = Mage::getModel('doofinder_feed/cron')->load($store->getCode(), 'store_code');
$lastGeneratedName = $process->getLastFeedName();

$fileUrl = Mage::getBaseUrl('media').'doofinder'.DS.$lastGeneratedName;
$fileDir = Mage::getBaseDir('media').DS.'doofinder'.DS.$lastGeneratedName;
if ($lastGeneratedName && file_exists($fileDir)) {
$files[$store->getCode()] = "<a href='{$fileUrl}' target='_blank'>" . (count($stores) > 1 ? $fileUrl : "Get {$lastGeneratedName}") . "</a>";
if (!$store->getConfig('doofinder_cron/schedule_settings/enabled')) {
$message = $helper->__('Cron-based feed generation is <strong>disabled</strong>.');
} else {
$files[$store->getCode()] = "Currently there is no file to preview.";
$enabled = true;
$process = Mage::getModel('doofinder_feed/cron')->load($store->getCode(), 'store_code');
$lastGeneratedName = $process->getLastFeedName();

$fileUrl = Mage::getBaseUrl('media').'doofinder'.DS.$lastGeneratedName;
$fileDir = Mage::getBaseDir('media').DS.'doofinder'.DS.$lastGeneratedName;

if ($lastGeneratedName && file_exists($fileDir)) {
$message = '<p><a href=' . $fileUrl . ' target="_blank">';
$message .= count($stores) > 1 ? $fileUrl : $helper->__('Get %s', $lastGeneratedName);
$message .= '</a></p>';
} else {
$message = '<p>' . $helper->__('Currently there is no file to preview.') . '</p>';
}

$time = explode(',', Mage::getStoreConfig('doofinder_cron/schedule_settings/time', $store->getCode()));
$frequency = Mage::getStoreConfig('doofinder_cron/schedule_settings/frequency', $store->getCode());
$message .= '<p>';
$message .= $helper->__('Cron-based feed generation is <strong>enabled</strong>. Feed generation is being scheduled at %s:%s.', $time[0], $time[1]);
$message .= '</p>';
}

$messages[$store->getName()] = $message;
}

$html = '';

if (count($files) > 1) {
$html .= '<ul>';
foreach ($files as $code => $file) {
$html .= '<li><b>' . $stores[$code]->getName() . ':</b><div>' . $file . '</div></li>';
}
$html .= '</ul>';
} else {
$html .= reset($files);
if ($enabled) {
$html .= $this->getCronMessage();
}

if (count(array_unique($messages)) == 1) {
return $html . reset($messages);
}

$html .= '<ul>';
foreach ($messages as $name => $message) {
$html .= '<li><strong>' . $name . ':</strong><p>' . $message . '</p></li>';
}
$html .= '</ul>';

return $html;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_LayerDescription extends Doofinder_Feed_Block_Settings_Panel_Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @category blocks
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

class Doofinder_Feed_Block_Settings_Panel_Message extends Mage_Adminhtml_Block_System_Config_Form_Field
Expand Down
4 changes: 2 additions & 2 deletions app/code/community/Doofinder/Feed/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
/**
* @category Helpers
* @package Doofinder_Feed
* @version 1.8.8
* @version 1.8.9
*/

/**
* Data helper for Doofinder Feed
*
* @version 1.8.8
* @version 1.8.9
* @package Doofinder_Feed
*/
class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
Expand Down
Loading

0 comments on commit 69ac302

Please sign in to comment.