Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

Commit

Permalink
1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Magmodules committed May 30, 2017
0 parents commit a118d60
Show file tree
Hide file tree
Showing 24 changed files with 965 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
*.zip
.DS_Store
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Kiyoh Rich Snippets for Magento® 1

Show your ratings from KiyOh on your homepage and use them for the Rich Snippets so the Rich Snippets will be shown in the most popular search engines.

## Development by Magmodules

We are a Dutch Magento® Only Agency dedicated to the development of extensions for Magento® 1 and Magento® 2. All our extensions are coded by our own team and our support team is always there to help you out.

## Links

[Visit Magmodules.eu](https://www.magmodules.eu/)

[Terms and Conditions](https://www.magmodules.eu/terms.html)

[Contact Us](https://www.magmodules.eu/contact-us.html)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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_Kiyohsnippets
* @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_Kiyohsnippets_Block_Adminhtml_System_Config_Form_Field_Heading
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)
{
$useContainerId = $element->getData('use_container_id');
return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4>%s</h4></td></tr>',
$element->getHtmlId(), $element->getLabel()
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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_Kiyohsnippets
* @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_Kiyohsnippets_Block_Adminhtml_System_Config_Form_Field_Version
extends Mage_Adminhtml_Block_System_Config_Form_Field
{

/**
* @param Varien_Data_Form_Element_Abstract $element
*
* @return mixed
*/
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
return Mage::getConfig()->getNode()->modules->Magmodules_Kiyohsnippets->version;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?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_Kiyohsnippets
* @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_Kiyohsnippets_Block_Adminhtml_Widget_Info_Info
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)
{

$magento_version = Mage::getVersion();
$module_version = Mage::getConfig()->getNode()->modules->Magmodules_Kiyohsnippets->version;
$logo_link = '//www.magmodules.eu/logo/kiyohsnippets/' . $module_version . '/' . $magento_version . '/logo.png';

$html = '<div style="background:url(\'' . $logo_link . '\') no-repeat scroll 15px center #EAF0EE;border:1px solid #CCCCCC;margin-bottom:10px;padding:10px 5px 5px 200px;">
<h4>About Magmodules.eu</h4>
<p>We are a Magento only E-commerce Agency located in the Netherlands.<br>
<br />
<table width="500px" border="0">
<tr>
<td width="58%">View more extensions from us:</td>
<td width="42%"><a href="http://www.magentocommerce.com/magento-connect/developer/Magmodules" target="_blank">Magento Connect</a></td>
</tr>
<tr>
<td>Send us an E-mail:
<td><a href="mailto:[email protected]">[email protected]</a></td>
</tr>
<tr>
<td height="30">Visit our website:</td>
<td><a href="http://www.magmodules.eu" target="_blank">www.magmodules.eu</a></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="30"><strong>Need help?</strong></td>
<td><strong><a href="http://www.magmodules.eu/help/kiyoh-rich-snippets" target="_blank">Online manual</a></strong></td>
</tr>
</table>
</div>';
return $html;
}

}
70 changes: 70 additions & 0 deletions app/code/local/Magmodules/Kiyohsnippets/Block/Snippets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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_Kiyohsnippets
* @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_Kiyohsnippets_Block_Snippets extends Mage_Core_Block_Template
{

/**
* @return mixed
*/
public function getSnapshopRequest()
{
return $this->helper('kiyohsnippets')->getSnapshopRequest();
}

/**
* @return mixed
*/
public function getKiyohLink()
{
return $this->helper('kiyohsnippets')->getKiyohLink();
}

/**
* @param $rating
*
* @return mixed
*/
public function getKiyohStars($rating)
{
return $this->helper('kiyohsnippets')->getKiyohStars($rating);
}

/**
*
*/
protected function _construct()
{
parent::_construct();
$this->addData(array(
'cache_lifetime' => 7200,
'cache_tags' => array(Mage_Cms_Model_Block::CACHE_TAG, 'kiyohsnippets_block'),
'cache_key' => 'kiyohsnippets-snippets-block',
));
if (Mage::getStoreConfig('kiyohsnippets/api/enabled')) {
$snippets = $this->helper('kiyohsnippets')->getSnapshopRequest();
if ($snippets) {
$this->setSnippets($snippets);
$this->setTemplate('magmodules/kiyohsnippets/block.phtml');
}
}
}

}
133 changes: 133 additions & 0 deletions app/code/local/Magmodules/Kiyohsnippets/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?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_Kiyohsnippets
* @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_Kiyohsnippets_Helper_Data extends Mage_Core_Helper_Abstract
{

/**
* @return array|bool
*/
function getSnapshopRequest()
{
$kiyohShopId = Mage::getStoreConfig('kiyohsnippets/api/shop_id');
$apiUrl = Mage::getStoreConfig('kiyohsnippets/api/api_url');
$dataType = Mage::getStoreConfig('kiyohsnippets/api/data_type');
$textSuffix = Mage::getStoreConfig('kiyohsnippets/api/kiyoh_suffix');

$filename = 'https://' . $apiUrl . '/widgetfeed.php?company=';

if (!$kiyohShopId) {
return false;
}

$xml = $this->getXml($filename . $kiyohShopId, 1);

if (!$xml) {
return false;
}

$xmlData = $xml->channel->description;

$qty = explode(' ', $xmlData);
$qty = array_pop($qty);

if (empty($qty)) {
return false;
}

if (empty($dataType)) {
$max = '10';
$data = explode(',', $xmlData);
$data = explode(' ', $data[0]);
$data = array_pop($data);
$percentage = ($data * 10);
} else {
$data = '';
$max = '100';
if (preg_match("/[0-9]+%/", $xmlData, $matches)) {
$data = substr($matches[0], 0, -1);
}
$percentage = $data;
$data = $data . '%';
}

$snippets = array();
$snippets['qty'] = $qty;
$snippets['avg'] = $data;
$snippets['max'] = $max;
$snippets['percentage'] = $percentage;
$snippets['data_type'] = $dataType;
$snippets['text_suffix'] = $textSuffix;

return $snippets;
}

/**
* @param $url
* @param int $timeout
*
* @return bool|SimpleXMLElement
*/
public function getXml($url, $timeout = 0)
{
$ch = curl_init($url);
curl_setopt_array($ch, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => (int)$timeout));
if ($xml = curl_exec($ch)) {
return simplexml_load_string($xml);
} else {
return false;
}
}

/**
* @return bool|mixed
*/
function getKiyohLink()
{
$showLink = Mage::getStoreConfig('kiyohsnippets/api/show_link');

if (!$showLink) {
return false;
}

$kiyohLink = Mage::getStoreConfig('kiyohsnippets/api/kiyoh_link');
return $kiyohLink;
}

/**
* @param $rating
*
* @return bool|string
*/
function getKiyohStars($rating)
{
$showStars = Mage::getStoreConfig('kiyohsnippets/api/show_stars');
if (!$showStars) {
return false;
}

$html = '<div class="rating-box">';
$html .= ' <div class="rating" style="width:' . $rating . '%"></div>';
$html .= '</div>';

return $html;
}

}
Loading

0 comments on commit a118d60

Please sign in to comment.