Skip to content
This repository has been archived by the owner on Jan 26, 2018. It is now read-only.

Commit

Permalink
Merge pull request #2 from Magmodules/development
Browse files Browse the repository at this point in the history
1.5.1
  • Loading branch information
Magmodules authored May 2, 2017
2 parents 2f1cf27 + f30515b commit 2a4c3ff
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Magmodules.eu - http://www.magmodules.eu
*
* NOTICE OF LICENSE
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Magmodules
* @package Magmodules_Feedbackcompany
* @author Magmodules <[email protected]>
* @copyright Copyright (c) 2017 (http://www.magmodules.eu)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Magmodules_Feedbackcompany_Block_Adminhtml_Widget_Form_Apicomment extends Mage_Adminhtml_Block_Abstract
implements Varien_Data_Form_Element_Renderer_Interface
{

/**
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
return sprintf(
'<tr id="row_%s"><td colspan="5" class="label">%s<br/></td></tr>',
$element->getHtmlId(),
$this->getNoteData()
);
}

/**
* @return string
*/
public function getNoteData()
{
$url = $this->getUrl('*/feedbackreviews/process');
return $this->__('Please run the <a href="%s">full</a> update process after changing the API datails.', $url);
}

}
99 changes: 17 additions & 82 deletions app/code/community/Magmodules/Feedbackcompany/Block/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,58 +27,17 @@ class Magmodules_Feedbackcompany_Block_Sidebar extends Mage_Core_Block_Template
*/
public function getSidebarCollection($sidebar)
{
$enabled = '';
$qty = '5';
if (Mage::getStoreConfig('feedbackcompany/general/enabled')) {
if ($sidebar == 'left') {
$qty = Mage::getStoreConfig('feedbackcompany/sidebar/left_qty');
$enabled = Mage::getStoreConfig('feedbackcompany/sidebar/left');
}

if ($sidebar == 'right') {
$qty = Mage::getStoreConfig('feedbackcompany/sidebar/right_qty');
$enabled = Mage::getStoreConfig('feedbackcompany/sidebar/right');
}
}

if ($enabled) {
$shopId = Mage::getStoreConfig('feedbackcompany/general/api_id');
$collection = Mage::getModel("feedbackcompany/reviews")->getCollection();
$collection->setOrder('date_created', 'DESC');
$collection->addFieldToFilter('status', 1);
$collection->addFieldToFilter('sidebar', 1);
$collection->addFieldToFilter('shop_id', array('eq' => array($shopId)));
$collection->setPageSize($qty);
$collection->load();

return $collection;
} else {
return false;
}
return Mage::helper('feedbackcompany')->getSidebarCollection($sidebar);
}

/**
* @param $sidebarreview
* @param $review
* @param string $sidebar
* @return mixed
*/
public function formatContent($sidebarreview, $sidebar = 'left')
public function formatContent($review, $sidebar = 'left')
{
$content = $sidebarreview->getReviewText();
$charLimit = '120';

if ($sidebar == 'left') {
$charLimit = Mage::getStoreConfig('feedbackcompany/sidebar/left_lenght');
}

if ($sidebar == 'right') {
$charLimit = Mage::getStoreConfig('feedbackcompany/sidebar/right_lenght');
}

$content = Mage::helper('core/string')->truncate($content, $charLimit, ' ...');

return $content;

return Mage::helper('feedbackcompany')->formatContent($review, $sidebar);
}

/**
Expand All @@ -87,30 +46,11 @@ public function formatContent($sidebarreview, $sidebar = 'left')
*/
public function getReviewsUrl($sidebar = 'left')
{
$url = '';
$link = '';

if ($sidebar == 'left') {
$link = Mage::getStoreConfig('feedbackcompany/sidebar/left_link');
}

if ($sidebar == 'right') {
$link = Mage::getStoreConfig('feedbackcompany/sidebar/right_link');
}

if ($link == 'internal') {
$url = $this->getUrl('feedbackcompany');
}

if ($link == 'external') {
$url = Mage::getStoreConfig('feedbackcompany/general/url');
}

if ($url) {
if($url = Mage::helper('feedbackcompany')->getReviewsUrl($sidebar)) {
return '<a href="' . $url . '" target="_blank">' . $this->__('View all reviews') . '</a>';
} else {
return false;
}

return false;
}

/**
Expand All @@ -119,21 +59,7 @@ public function getReviewsUrl($sidebar = 'left')
*/
public function getSnippetsEnabled($sidebar = 'left')
{
$enabled = '';

if ($sidebar == 'left') {
$enabled = Mage::getStoreConfig('feedbackcompany/sidebar/left_snippets');
}

if ($sidebar == 'right') {
$enabled = Mage::getStoreConfig('feedbackcompany/sidebar/right_snippets');
}

if ($enabled && ($this->getRequest()->getRouteName() != 'feedbackcompany')) {
return true;
}

return false;
return Mage::helper('feedbackcompany')->getSnippetsEnabled($sidebar);
}

/**
Expand All @@ -144,14 +70,23 @@ public function getTotalScore()
return $this->helper('feedbackcompany')->getTotalScore();
}

/**
* @param $votes
*
* @return string
*/
public function getVotesHtml($votes)
{
return $this->__('Based on %s reviews', '<span itemprop="ratingCount">' .$votes . '</span>');
}

/**
* @return string
*/
public function getLogoHtml()
{
$img = $this->getSkinUrl('magmodules/feedbackcompany/images/logo.png');
return '<img src="' . $img .'" class="feedbackcompany-logo">';
}

}
6 changes: 3 additions & 3 deletions app/code/community/Magmodules/Feedbackcompany/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ public function getLatestReview()
}

/**
* @param $sidebarreview
* @param $review
* @param string $sidebar
*
* @return string
*/
public function formatContent($sidebarreview, $sidebar = 'left')
public function formatContent($review, $sidebar = 'left')
{
$content = $sidebarreview->getReviewText();
$content = $review->getReviewText();
$charLimit = '';
if ($sidebar == 'left') {
$charLimit = Mage::getStoreConfig('feedbackcompany/sidebar/left_lenght');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function runUpdate($storeId, $type)

$createdAt = $this->reformatDate($review['date_created']);
$nickName = $review['client']['name'];
$ratingVal = $review['rating'];
$id = $review['id'];

$review = Mage::getModel('review/review');
Expand All @@ -96,7 +97,7 @@ public function runUpdate($storeId, $type)
$rating->setRatingId($ratingId);
$rating->setReviewId($review->getId());
$rating->setCustomerId(null);
$rating->addOptionVote($options[$id], $productId);
$rating->addOptionVote($options[$ratingVal], $productId);
$review->aggregate();
}
} catch (Exception $e) {
Expand Down
15 changes: 0 additions & 15 deletions app/code/community/Magmodules/Feedbackcompany/Model/Reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,4 @@ public function reformatDate($date)
return $datetime->format('Y-m-d H:i:s');
}

/**
* Flush Cache function
*/
public function flushCache()
{
if (Mage::getStoreConfig(self::XML_FLUSH_CACHE)) {
Mage::app()->cleanCache(
array(
Mage_Cms_Model_Block::CACHE_TAG,
Magmodules_Feedbackcompany_Model_Reviews::CACHE_TAG
)
);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public function massDisableAction()
}
}

Mage::getModel('feedbackcompany/reviews')->flushCache();
$this->_redirect('*/*/index');
}

Expand All @@ -175,7 +174,6 @@ public function massEnableAction()
}
}

Mage::getModel('feedbackcompany/reviews')->flushCache();
$this->_redirect('*/*/index');
}

Expand All @@ -202,7 +200,6 @@ public function massEnableSidebarAction()
}
}

Mage::getModel('feedbackcompany/reviews')->flushCache();
$this->_redirect('*/*/index');
}

Expand All @@ -228,7 +225,6 @@ public function massDisableSidebarAction()
}
}

Mage::getModel('feedbackcompany/reviews')->flushCache();
$this->_redirect('*/*/index');
}

Expand All @@ -247,7 +243,6 @@ public function truncateAction()
$msg = $this->__('Succefully deleted all %s saved review(s).', $i);

Mage::getSingleton('adminhtml/session')->addSuccess($msg);
Mage::getModel('feedbackcompany/reviews')->flushCache();
$this->_redirect('*/*/index');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<config>
<modules>
<Magmodules_Feedbackcompany>
<version>1.5.0</version>
<version>1.5.1</version>
</Magmodules_Feedbackcompany>
</modules>
<global>
Expand Down
Loading

0 comments on commit 2a4c3ff

Please sign in to comment.