Version Notes
The first release of ShopGo Core module.
Download this release
Release Info
| Developer | Moe Ghashim |
| Extension | Shopgo_Core |
| Version | 1.0.6 |
| Comparing to | |
| See all releases | |
Version 1.0.6
app/code/community/Shopgo/Core/Helper/Abstract.php
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* ShopGo
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Shopgo
|
| 13 |
+
* @package Shopgo_Core
|
| 14 |
+
* @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Abstract helper class
|
| 21 |
+
*
|
| 22 |
+
* @category Shopgo
|
| 23 |
+
* @package Shopgo_Core
|
| 24 |
+
* @author Ammar <ammar@shopgo.me>
|
| 25 |
+
*/
|
| 26 |
+
abstract class Shopgo_Core_Helper_Abstract extends Mage_Core_Helper_Abstract
|
| 27 |
+
{
|
| 28 |
+
/**
|
| 29 |
+
* Log file name
|
| 30 |
+
*
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
protected $_logFile = 'shopgo.log';
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Email fail message
|
| 37 |
+
*
|
| 38 |
+
* @var string
|
| 39 |
+
*/
|
| 40 |
+
protected $_emailFailMessage = 'Could not send email';
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Send email
|
| 44 |
+
*
|
| 45 |
+
* @param string $to
|
| 46 |
+
* @param int|string $templateId
|
| 47 |
+
* @param array $params
|
| 48 |
+
* @param string|array $sender
|
| 49 |
+
* @param string $name
|
| 50 |
+
* @param int|null $storeId
|
| 51 |
+
* @return bool
|
| 52 |
+
*/
|
| 53 |
+
public function sendEmail($to, $templateId, $params = array(), $sender = 'general', $name = null, $storeId = null)
|
| 54 |
+
{
|
| 55 |
+
$mailTemplate = Mage::getModel('core/email_template');
|
| 56 |
+
$translate = Mage::getSingleton('core/translate');
|
| 57 |
+
$result = true;
|
| 58 |
+
|
| 59 |
+
if (empty($storeView)) {
|
| 60 |
+
$storeId = Mage::app()->getStore()->getId();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
if (isset($params['subject'])) {
|
| 64 |
+
$mailTemplate->setTemplateSubject($params['subject']);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
$mailTemplate->sendTransactional(
|
| 68 |
+
$templateId,
|
| 69 |
+
$sender,
|
| 70 |
+
$to,
|
| 71 |
+
$name,
|
| 72 |
+
$params,
|
| 73 |
+
$storeId
|
| 74 |
+
);
|
| 75 |
+
|
| 76 |
+
if (!$mailTemplate->getSentSuccess()) {
|
| 77 |
+
$this->log($this->_emailFailMessage);
|
| 78 |
+
$result = false;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
$translate->setTranslateInline(true);
|
| 82 |
+
|
| 83 |
+
return $result;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Set user messages
|
| 88 |
+
*
|
| 89 |
+
* @param string|array $message
|
| 90 |
+
* @param string $type
|
| 91 |
+
* @param string $sessionPath
|
| 92 |
+
* @return bool
|
| 93 |
+
*/
|
| 94 |
+
public function userMessage($message, $type, $sessionPath = 'core/session')
|
| 95 |
+
{
|
| 96 |
+
try {
|
| 97 |
+
$session = Mage::getSingleton($sessionPath);
|
| 98 |
+
|
| 99 |
+
if (is_array($message)) {
|
| 100 |
+
if (!isset($message['text'])) {
|
| 101 |
+
return false;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
if (isset($message['translate'])) {
|
| 105 |
+
$message = $this->__($message['text']);
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
switch ($type) {
|
| 110 |
+
case 'error':
|
| 111 |
+
$session->addError($message);
|
| 112 |
+
break;
|
| 113 |
+
case 'success':
|
| 114 |
+
$session->addSuccess($message);
|
| 115 |
+
break;
|
| 116 |
+
case 'notice':
|
| 117 |
+
$session->addNotice($message);
|
| 118 |
+
break;
|
| 119 |
+
}
|
| 120 |
+
} catch (Exception $e) {
|
| 121 |
+
$this->log($e, 'exception');
|
| 122 |
+
return false;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
return true;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* Generate log
|
| 130 |
+
*
|
| 131 |
+
* @param string|array $logs
|
| 132 |
+
* @param string $type
|
| 133 |
+
* @param string $file
|
| 134 |
+
* @return bool
|
| 135 |
+
*/
|
| 136 |
+
public function log($logs, $type = 'system', $file = '')
|
| 137 |
+
{
|
| 138 |
+
if (!Mage::getStoreConfig('dev/log/active')
|
| 139 |
+
|| empty($logs)) {
|
| 140 |
+
return;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
if (empty($file)) {
|
| 144 |
+
$file = $this->_logFile;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
switch ($type) {
|
| 148 |
+
case 'exception':
|
| 149 |
+
if (!is_array($logs)) {
|
| 150 |
+
$logs = array($logs);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
foreach ($logs as $log) {
|
| 154 |
+
if (!$log instanceof Exception) {
|
| 155 |
+
continue;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
Mage::logException($log);
|
| 159 |
+
}
|
| 160 |
+
break;
|
| 161 |
+
default:
|
| 162 |
+
$this->_systemLog($logs, $file);
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Generate system log
|
| 168 |
+
*
|
| 169 |
+
* @param string|array $logs
|
| 170 |
+
* @param string $file
|
| 171 |
+
* @return null
|
| 172 |
+
*/
|
| 173 |
+
private function _systemLog($logs, $file)
|
| 174 |
+
{
|
| 175 |
+
if (is_string($logs)) {
|
| 176 |
+
$logs = array(array('message' => $logs));
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
foreach ($logs as $log) {
|
| 180 |
+
if (!isset($log['message'])) {
|
| 181 |
+
continue;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
$message = $log['message'];
|
| 185 |
+
|
| 186 |
+
$level = isset($log['level'])
|
| 187 |
+
? $log['level'] : null;
|
| 188 |
+
|
| 189 |
+
if (!empty($log['file'])) {
|
| 190 |
+
$file = $log['file'];
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
if (false === strpos($file, '.log')) {
|
| 194 |
+
$file .= '.log';
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
$forceLog = isset($log['forceLog'])
|
| 198 |
+
? $log['forceLog'] : false;
|
| 199 |
+
|
| 200 |
+
Mage::log($message, $level, $file, $forceLog);
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
/**
|
| 205 |
+
* Check whether Advanced Ifconfig module is enabled or not
|
| 206 |
+
*
|
| 207 |
+
* @return bool
|
| 208 |
+
*/
|
| 209 |
+
public function isAdvIfconfigEnabled()
|
| 210 |
+
{
|
| 211 |
+
return Mage::helper('core')->isModuleEnabled('Shopgo_AdvIfconfig');
|
| 212 |
+
}
|
| 213 |
+
}
|
app/code/community/Shopgo/Core/Helper/Data.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* ShopGo
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Shopgo
|
| 13 |
+
* @package Shopgo_Core
|
| 14 |
+
* @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Data helper
|
| 21 |
+
*
|
| 22 |
+
* @category Shopgo
|
| 23 |
+
* @package Shopgo_Core
|
| 24 |
+
* @author Ammar <ammar@shopgo.me>
|
| 25 |
+
*/
|
| 26 |
+
class Shopgo_Core_Helper_Data extends Shopgo_Core_Helper_Abstract
|
| 27 |
+
{
|
| 28 |
+
|
| 29 |
+
}
|
app/code/community/Shopgo/Core/etc/config.xml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* ShopGo
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 12 |
+
*
|
| 13 |
+
* @category Shopgo
|
| 14 |
+
* @package Shopgo_Core
|
| 15 |
+
* @author Ammar <ammar@shopgo.me>
|
| 16 |
+
* @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
|
| 17 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 18 |
+
*/
|
| 19 |
+
-->
|
| 20 |
+
<config>
|
| 21 |
+
<modules>
|
| 22 |
+
<Shopgo_Core>
|
| 23 |
+
<version>1.0.6</version>
|
| 24 |
+
</Shopgo_Core>
|
| 25 |
+
</modules>
|
| 26 |
+
<global>
|
| 27 |
+
<helpers>
|
| 28 |
+
<shopgo_core>
|
| 29 |
+
<class>Shopgo_Core_Helper</class>
|
| 30 |
+
</shopgo_core>
|
| 31 |
+
</helpers>
|
| 32 |
+
</global>
|
| 33 |
+
</config>
|
app/etc/modules/Shopgo_Core.xml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* ShopGo
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 12 |
+
*
|
| 13 |
+
* @category Shopgo
|
| 14 |
+
* @package Shopgo_Core
|
| 15 |
+
* @author Ammar <ammar@shopgo.me>
|
| 16 |
+
* @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
|
| 17 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 18 |
+
*/
|
| 19 |
+
-->
|
| 20 |
+
<config>
|
| 21 |
+
<modules>
|
| 22 |
+
<Shopgo_Core>
|
| 23 |
+
<active>true</active>
|
| 24 |
+
<codePool>community</codePool>
|
| 25 |
+
</Shopgo_Core>
|
| 26 |
+
</modules>
|
| 27 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Shopgo_Core</name>
|
| 4 |
+
<version>1.0.6</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>A core module that other ShopGo modules depend on.</summary>
|
| 10 |
+
<description>ShopGo Core is a utility module that contains functions used by other ShopGo modules.
|
| 11 |
+

|
| 12 |
+
You could also get the latest version of the module from:
|
| 13 |
+
<a href="https://github.com/shopgo-me/shopgo-core" target="_blank">https://github.com/shopgo-me/shopgo-core</a></description>
|
| 14 |
+
<notes>The first release of ShopGo Core module.</notes>
|
| 15 |
+
<authors><author><name>ShopGo</name><user>ShopGo</user><email>support@shopgo.me</email></author></authors>
|
| 16 |
+
<date>2015-07-06</date>
|
| 17 |
+
<time>22:47:09</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Shopgo"><dir name="Core"><dir name="Helper"><file name="Abstract.php" hash="e1cd92ebe053c0911dfd187730ec166b"/><file name="Data.php" hash="c84877784eb944531eaae07862160672"/></dir><dir name="etc"><file name="config.xml" hash="66e0f912a47cccc971cc36f61eb16edc"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shopgo_Core.xml" hash="89ed1d6c6b558de4c50a62681117c854"/></dir></target></contents>
|
| 19 |
+
<compatible/>
|
| 20 |
+
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
| 21 |
+
</package>
|
