Commit 4c1b4b94 authored by brokentwill's avatar brokentwill

Initial commit

parents
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Block_Notification_Window extends Mage_Adminhtml_Block_Notification_Window{
protected function _construct(){
parent::_construct();
if(!Mage::getStoreConfig('obbase/install/run')){
$c = Mage::getModel('core/config_data');
$c->setScope('default')
->setPath('obbase/install/run')
->setValue(time())
->save();
$this->setHeaderText($this->__("OnlineBiz Notifications Setup"));
$this->setIsFirstRun(1);
$this->setIsHtml(1);
}
}
protected function _toHtml(){
if($this->getIsHtml()){
$this->setTemplate('onlinebizsoft/obbase/notification/window.phtml');
}
return parent::_toHtml();
}
public function presetFirstSetup(){
}
public function getNoticeMessageText(){
return $this->getData('notice_message_text');
}
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Block_Store extends Mage_Adminhtml_Block_Template
{
protected $_extensions_cache = array();
protected $_extensions;
protected $_section = '';
protected $_store_data = null;
protected function _prepareLayout()
{
$this->_section = $this->getAction()->getRequest()->getParam('section', false);
if($this->_section == 'storeview') {
$this->getLayout()
->getBlock('head')
->addJs('onlinebizsoft/obbase/base.js');
}
$this->setData('store_data', $this->_getStoreData());
parent::_prepareLayout();
}
/**
* @return string
*/
protected function _toHtml()
{
if ($this->_section == 'storeview') {
return parent::_toHtml();
} else {
return '';
}
}
/**
* Fetch store data and return as Varien Object
* @return Varien_Object
*/
protected function _getStoreData()
{
if (!is_null($this->_store_data))
return $this->_store_data;
$storeData = array();
$connection = $this->_getStoreConnection();
$storeResponse = $connection->read();
if ($storeResponse !== false) {
$storeResponse = preg_split('/^\r?$/m', $storeResponse, 2);
$storeResponse = trim($storeResponse[1]);
Mage::app()->saveCache($storeResponse, OnlineBiz_ObBase_Helper_Config::STORE_RESPONSE_CACHE_KEY);
}
else {
$storeResponse = Mage::app()->loadCache(OnlineBiz_ObBase_Helper_Config::STORE_RESPONSE_CACHE_KEY);
if (!$storeResponse) {
//Mage::getSingleton('adminhtml/session')->addError($this->__('Sorry, but Extensions Store is not available now. Please try again in a few minutes.'));
}
}
$connection->close();
$this->_store_data = new Varien_Object(array('text_response' => $storeResponse));
return $this->_store_data;
}
/**
* Returns URL to store
* @return Varien_Http_Adapter_Curl
*/
protected function _getStoreConnection()
{
$params = array(
);
$url = array();
foreach ($params as $k => $v) {
$url[] = urlencode($k) . "=" . urlencode($v);
}
$url = rtrim(OnlineBiz_ObBase_Helper_Config::STORE_URL) . (sizeof($url) ? ("?" . implode("&", $url)) : "");
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array(
'timeout' => 5
));
$curl->write(Zend_Http_Client::GET, $url, '1.0');
return $curl;
}
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Block_System_Config_Form_Fieldset_Conflict
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
{
protected $_dummyElement;
protected $_fieldRenderer;
protected $_values;
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = $this->_getHeaderHtml($element);
$html .= '<table cellpadding="5" cellspacing="5">';
//retrieve all config.xml
$tConfigFiles = $this->getConfigFilesList();
//parse all config.xml
$rewrites = array();
foreach($tConfigFiles as $configFile)
{
$rewrites = $this->getRewriteForFile($configFile, $rewrites);
}
$i = 0;
foreach($rewrites as $key => $value)
{
$i++;
$t = explode('/', $key);
$moduleName = $t[0];
$className = $t[1];
$rewriteClasses = join(', ', $value);
$conflict = 0;
if (count($value) > 1)
$conflict = 1;
$html.= $this->_getFieldHtml($element, $moduleName, $className, $rewriteClasses, $conflict);
}
$html .= '</table>';
$html .= $this->_getFooterHtml($element);
return $html;
}
protected function _getDummyElement()
{
if (empty($this->_dummyElement)) {
$this->_dummyElement = new Varien_Object(array('show_in_default'=>1, 'show_in_website'=>1));
}
return $this->_dummyElement;
}
protected function _getFieldRenderer()
{
if (empty($this->_fieldRenderer)) {
$this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
}
return $this->_fieldRenderer;
}
protected function _getFieldHtml($fieldset, $moduleName, $className, $rewriteClasses, $conflict)
{
$html = '<tr>';
if($conflict)
$conflict = '<font color="red">'.Mage::helper('obbase')->__("Yes").'</font>';
else
$conflict = Mage::helper('obbase')->__("No");
$html .='<td width="80">'.$moduleName.'</td><td>'.$className.'</td><td>'.$rewriteClasses.'</td><td>'.$conflict.'</td>';
$html .= '</tr>';
return $html;
}
protected function _convertVersion($v){
$digits = @explode(".", $v);
$version = 0;
if(is_array($digits)){
foreach($digits as $k=>$v){
$version += ($v * pow(10, max(0, (3-$k))));
}
}
return $version;
}
/**
*
*
* @param unknown_type $dirName
* @return unknown
*/
private function directoryIsValid($dirName)
{
switch ($dirName) {
case '.':
case '..':
case '':
return false;
break;
default:
return true;
break;
}
}
private function manageModule($moduleName)
{
switch ($moduleName) {
case 'global':
return false;
break;
default:
return true;
break;
}
}
/**
* create an array with all config.xml files
*
*/
public function getConfigFilesList()
{
$retour = array();
//$codePath = Mage::getStoreConfig('system/filesystem/code');
$codePath = BP . DS . 'app' . DS . 'code';
$tmpPath = Mage::app()->getConfig()->getTempVarDir().'/obexconflict/';
if (!is_dir($tmpPath))
mkdir($tmpPath);
$locations = array();
$locations[] = $codePath.'/local/';
$locations[] = $codePath.'/community/';
$locations[] = $tmpPath;
foreach ($locations as $location)
{
//parse every sub folders (means extension folders)
$poolDir = opendir($location);
while($namespaceName = readdir($poolDir))
{
if (!$this->directoryIsValid($namespaceName))
continue;
//parse modules within namespace
$namespacePath = $location.$namespaceName.'/';
$namespaceDir = opendir($namespacePath);
while($moduleName = readdir($namespaceDir))
{
if (!$this->directoryIsValid($moduleName))
continue;
$modulePath = $namespacePath.$moduleName.'/';
$configXmlPath = $modulePath.'etc/config.xml';
if (file_exists($configXmlPath))
$retour[] = $configXmlPath;
}
closedir($namespaceDir);
}
closedir($poolDir);
}
return $retour;
}
/**
* Return all rewrites for a config.xml
*
* @param unknown_type $configFilePath
*/
public function getRewriteForFile($configFilePath, $results)
{
//load xml
$xmlcontent = file_get_contents($configFilePath);
$domDocument = new DOMDocument();
$domDocument->loadXML($xmlcontent);
foreach($domDocument->documentElement->getElementsByTagName('rewrite') as $markup)
{
//parse child nodes
$moduleName = $markup->parentNode->tagName;
if ($this->manageModule($moduleName))
{
foreach($markup->getElementsByTagName('*') as $childNode)
{
//get information
$className = $childNode->tagName;
$rewriteClass = $childNode->nodeValue;
//add to result
$key = $moduleName.'/'.$className;
if (!isset($results[$key]))
$results[$key] = array();
$results[$key][] = $rewriteClass;
}
}
}
return $results;
}
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Block_System_Config_Form_Fieldset_Extensions
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
{
protected $_dummyElement;
protected $_fieldRenderer;
protected $_values;
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = $this->_getHeaderHtml($element);
$modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
sort($modules);
foreach ($modules as $moduleName) {
if (strstr($moduleName,'OnlineBiz_') === false) {
continue;
}
if($moduleName == 'OnlineBiz_Core' || $moduleName == 'OnlineBiz_ObBase'){
continue;
}
$html.= $this->_getFieldHtml($element, $moduleName);
}
$html .= $this->_getFooterHtml($element);
return $html;
}
protected function _getDummyElement()
{
if (empty($this->_dummyElement)) {
$this->_dummyElement = new Varien_Object(array('show_in_default'=>1, 'show_in_website'=>1));
}
return $this->_dummyElement;
}
protected function _getFieldRenderer()
{
if (empty($this->_fieldRenderer)) {
$this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
}
return $this->_fieldRenderer;
}
protected function _getFieldHtml($fieldset, $moduleName)
{
$configData = $this->getConfigData();
$path = 'advanced/modules_disable_output/'.$moduleName; //TODO: move as property of form
$data = isset($configData[$path]) ? $configData[$path] : array();
$e = $this->_getDummyElement();
$moduleKey = substr($moduleName, strpos($moduleName,'_')+1);
$ver = (Mage::getConfig()->getModuleConfig($moduleName)->version);
$id = $moduleName;
$hasUpdate = false;
if($displayNames = Mage::app()->loadCache('base_extensions_feed')){
if($displayNames = unserialize($displayNames)){
if(isset($displayNames[$moduleName])){
$url = @$displayNames[$moduleName]['url'];
$name = @$displayNames[$moduleName]['display_name'];
$version = @$displayNames[$moduleName]['version'];
$moduleName = '<a href="'.$url.'" target="_blank" title="'.$name.'">'.$name."</a>";
if($this->_convertVersion($ver) < $this->_convertVersion($version)){
$update = '<a href="'.$url.'" target="_blank"><img src="'.$this->getSkinUrl('onlinebizsoft/obbase/images/update.gif').'" title="'.$this->__("Update available").'"/></a>';
$hasUpdate = 1;
$moduleName ="$update $moduleName";
}
}
}
}
if(!$hasUpdate){
$update = '<a target="_blank"><img src="'.$this->getSkinUrl('onlinebizsoft/obbase/images/ok.gif').'" title="'.$this->__("Installed").'"/></a>';
$moduleName ="$update $moduleName";
}
if($ver){
$field = $fieldset->addField($id, 'label',
array(
'name' => 'ssssss',
'label' => $moduleName,
'value' => $ver,
))->setRenderer($this->_getFieldRenderer());
return $field->toHtml();
}
return '';
}
protected function _convertVersion($v){
$digits = @explode(".", $v);
$version = 0;
if(is_array($digits)){
foreach($digits as $k=>$v){
$version += ($v * pow(10, max(0, (3-$k))));
}
}
return $version;
}
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Block_System_Config_Form_Fieldset_Store extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
{
protected $_dummyElement;
protected $_fieldRenderer;
protected $_values;
public function render(Varien_Data_Form_Element_Abstract $element)
{
return '<div id="' . $element->getId() . '"></div>';
}
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Helper_Config extends Mage_Core_Helper_Abstract{
/** Extensions feed path */
const EXTENSIONS_FEED_URL = 'http://store.onlinebizsoft.com/feeds/extensions.xml';
/** Updates Feed path */
const UPDATES_FEED_URL = 'http://store.onlinebizsoft.com/feeds/updates.xml';
/** Store URL */
const STORE_URL = 'http://store.onlinebizsoft.com/store/';
/** Store response cache key*/
const STORE_RESPONSE_CACHE_KEY = 'onlinebiz_store_response_cache_key';
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Helper_Data extends Mage_Core_Helper_Abstract
{
public static function isActivated($module, $key=false, $generalConfig)
{
$servStr = $_SERVER['HTTP_HOST'];
$servStr = str_replace('https://', '', $servStr);
$servStr = str_replace('http://', '', $servStr);
$servStr = str_replace('www.', '', $servStr);
if((preg_match('/dev./',$servStr) || preg_match('/test./',$servStr) || preg_match('/demo./',$servStr)) && Mage::getStoreConfig($generalConfig))
return true;
if(($servStr == '127.0.0.1' || preg_match('/localhost/',$servStr)) && Mage::getStoreConfig($generalConfig))
return true;
if($key) {
if(base64_encode(md5($servStr.$module)) == $key && Mage::getStoreConfig($generalConfig))
return true;
}
$keys = preg_split("/(\r\n|\n|\r)/", Mage::getStoreConfig('managekey/general/keys'));
foreach($keys as $key){
if(base64_encode(md5($servStr.$module)) == $key && Mage::getStoreConfig($generalConfig)) {
return true;
}
}
return false;
}
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Model_Feed extends Mage_AdminNotification_Model_Feed
{
const XML_USE_HTTPS_PATH = 'obbase/feed/use_https';
const XML_FEED_URL_PATH = 'obbase/feed/url';
const XML_FREQUENCY_PATH = 'obbase/feed/check_frequency';
const XML_FREQUENCY_ENABLE = 'obbase/feed/enabled';
const XML_LAST_UPDATE_PATH = 'obbase/feed/last_update';
public static function check(){
return Mage::getModel('obbase/feed')->checkUpdate();
}
public function getFrequency(){
return 86400 * 3600;
}
public function getLastUpdate(){
return Mage::app()->loadCache('obbase_notifications_lastcheck');
}
public function setLastUpdate()
{
Mage::app()->saveCache(time(), 'obbase_notifications_lastcheck');
return $this;
}
public function getFeedUrl(){
if (is_null($this->_feedUrl)) {
$this->_feedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://')
. Mage::getStoreConfig(self::XML_FEED_URL_PATH);
}
return $this->_feedUrl;
}
public function checkUpdate(){
if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
return $this;
}
$feedData = array();
$feedXml = $this->getFeedData();
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
foreach ($feedXml->channel->item as $item) {
$feedData[] = array(
'severity' => (int)$item->severity ? (int)$item->severity : 3,
'date_added' => $this->getDate((string)$item->pubDate),
'title' => (string)$item->title,
'description' => (string)$item->description,
'url' => (string)$item->link,
);
}
if ($feedData) {
Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
}
}
$this->setLastUpdate();
return $this;
}
}
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Model_Feed_Abstract extends Mage_Core_Model_Abstract{
/**
* Retrieve feed data as XML element
*
* @return SimpleXMLElement
*/
public function getFeedData()
{
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array(
'timeout' => 1
));
$curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
$data = $curl->read();
if ($data === false) {
return false;
}
$data = preg_split('/^\r?$/m', $data, 2);
$data = trim($data[1]);
$curl->close();
try {
$xml = new SimpleXMLElement($data);
}
catch (Exception $e) {
return false;
}
return $xml;
}
/**
* Retrieve DB date from RSS date
*
* @param string $rssDate
* @return string YYYY-MM-DD YY:HH:SS
*/
public function getDate($rssDate)
{
return gmdate('Y-m-d H:i:s', strtotime($rssDate));
}
}
\ No newline at end of file
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Model_Feed_Extensions extends OnlineBiz_ObBase_Model_Feed_Abstract{
/**
* Retrieve feed url
*
* @return string
*/
public function getFeedUrl(){
return OnlineBiz_ObBase_Helper_Config::EXTENSIONS_FEED_URL;
}
/**
* Checks feed
* @return
*/
public function check(){
if(!(Mage::app()->loadCache('obbase_extensions_feed')) || (time()-Mage::app()->loadCache('obbase_extensions_feed_lastcheck')) > 86400){
$this->refresh();
}
}
public function refresh(){
$exts = array();
try{
$Node = $this->getFeedData();
if(!$Node) return false;
foreach($Node->children() as $ext){
$exts[(string)$ext->name] = array(
'display_name' => (string)$ext->display_name,
'version' => (string)$ext->version,
'url' => (string)$ext->url
);
}
Mage::app()->saveCache(serialize($exts), 'obbase_extensions_feed');
Mage::app()->saveCache(time(), 'obbase_extensions_feed_lastcheck');
return true;
}catch(Exception $E){
return false;
}
}
}
\ No newline at end of file
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Model_Feed_Updates extends OnlineBiz_ObBase_Model_Feed_Abstract{
/**
* Retrieve feed url
*
* @return string
*/
public function getFeedUrl(){
return OnlineBiz_ObBase_Helper_Config::UPDATES_FEED_URL;
}
/**
* Checks feed
* @return
*/
public function check(){
if((time()-Mage::app()->loadCache('obbase_updates_feed_lastcheck')) > Mage::getStoreConfig('obbase/feed/check_frequency')){
$this->refresh();
}
}
public function refresh(){
$feedData = array();
try{
$Node = $this->getFeedData();
if(!$Node) return false;
foreach($Node->children() as $item){
if($this->isInteresting($item)){
$date = strtotime((string)$item->date);
if(!Mage::getStoreConfig('obbase/install/run') || (Mage::getStoreConfig('obbase/install/run') < $date)){
$feedData[] = array(
'severity' => 3,
'date_added' => $this->getDate((string)$item->date),
'title' => (string)$item->title,
'description' => (string)$item->content,
'url' => (string)$item->url,
);
}
}
}
if ($feedData) {
Mage::getModel('adminnotification/inbox')->parse(($feedData));
}
Mage::app()->saveCache(time(), 'obbase_updates_feed_lastcheck');
return true;
}catch(Exception $E){
return false;
}
}
public function getInterests(){
if(!$this->getData('interests')){
$types = @explode(',', 'INFO,PROMO,UPDATE_RELEASE,NEW_RELEASE,INSTALLED_UPDATE');
$this->setData('interests', $types);
}
return $this->getData('interests');
}
/**
*
* @return
*/
public function isInteresting($item){
$interests = $this->getInterests();
$types = @explode(",", (string)$item->type);
$exts = @explode(",", (string)$item->extensions);
$isInterestedInSelfUpgrades = array_search(OnlineBiz_ObBase_Model_Source_Updates_Type::TYPE_INSTALLED_UPDATE, $types);
foreach($types as $type){
if(array_search($type, $interests) !== false){
return true;
}
if(($type == OnlineBiz_ObBase_Model_Source_Updates_Type::TYPE_UPDATE_RELEASE) && $isInterestedInSelfUpgrades){
foreach($exts as $ext){
if($this->isExtensionInstalled($ext)){
return true;
}
}
}
}
return false;
}
public function isExtensionInstalled($code){
$modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
foreach ($modules as $moduleName) {
if($moduleName == $code){
return true;
}
}
return false;
}
}
\ No newline at end of file
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
class OnlineBiz_ObBase_Model_Source_Updates_Type extends Mage_Eav_Model_Entity_Attribute_Source_Abstract{
const TYPE_PROMO = 'PROMO';
const TYPE_NEW_RELEASE = 'NEW_RELEASE';
const TYPE_UPDATE_RELEASE = 'UPDATE_RELEASE';
const TYPE_INFO = 'INFO';
const TYPE_INSTALLED_UPDATE = 'INSTALLED_UPDATE';
public function toOptionArray(){
return array(
array('value' => self::TYPE_INSTALLED_UPDATE, 'label' => Mage::helper('obbase')->__('My extensions updates')),
array('value' => self::TYPE_UPDATE_RELEASE, 'label' => Mage::helper('obbase')->__('All extensions updates')),
array('value' => self::TYPE_NEW_RELEASE, 'label' => Mage::helper('obbase')->__('New Releases')),
array('value' => self::TYPE_PROMO, 'label' => Mage::helper('obbase')->__('Promotions/Discounts')),
array('value' => self::TYPE_INFO, 'label' => Mage::helper('obbase')->__('Other information'))
);
}
/**
* Retrive all attribute options
*
* @return array
*/
public function getAllOptions()
{
return $this->toOptionArray();
}
/**
* Returns label for value
* @param string $value
* @return string
*/
public function getLabel($value){
$options = $this->toOptionArray();
foreach($options as $v){
if($v['value'] == $value){
return $v['label'];
}
}
return '';
}
/**
* Returns array ready for use by grid
* @return array
*/
public function getGridOptions(){
$items = $this->getAllOptions();
$out = array();
foreach($items as $item){
$out[$item['value']] = $item['label'];
}
return $out;
}
}
<?xml version="1.0"?>
<config>
<layout>
<updates>
<obbase module="obbase">
<file>onlinebizsoft/obbase.xml</file>
</obbase>
</updates>
</layout>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<managekey>
<title>Manage License Keys</title>
</managekey>
<obbase>
<title>Extentions Manager</title>
</obbase>
<storeview>
<title>OnlineBiz Extensions Store</title>
</storeview>
<conflict>
<title>Extensions Conflict</title>
</conflict>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config>
<modules>
<OnlineBiz_ObBase>
<version>0.1.0</version>
</OnlineBiz_ObBase>
</modules>
<global>
<blocks>
<obbase>
<class>OnlineBiz_ObBase_Block</class>
</obbase>
<adminhtml>
<rewrite>
<notification_window>OnlineBiz_ObBase_Block_Notification_Window</notification_window>
</rewrite>
</adminhtml>
</blocks>
<resources>
<obbase_setup>
<setup>
<module>OnlineBiz_ObBase</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</obbase_setup>
<obbase_write>
<connection>
<use>core_write</use>
</connection>
</obbase_write>
<obbase_read>
<connection>
<use>core_read</use>
</connection>
</obbase_read>
</resources>
<models>
<obbase>
<class>OnlineBiz_ObBase_Model</class>
</obbase>
</models>
<helpers>
<obbase>
<class>OnlineBiz_ObBase_Helper</class>
</obbase>
</helpers>
</global>
<adminhtml>
<layout>
<updates>
<obbase module="obbase">
<file>onlinebizsoft/obbase.xml</file>
</obbase>
</updates>
</layout>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<managekey>
<title>Manage License Keys</title>
</managekey>
<obbase>
<title>Extentions Manager</title>
</obbase>
<storeview>
<title>OnlineBiz Extensions Store</title>
</storeview>
<conflict>
<title>Extensions Conflict</title>
</conflict>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
<events>
<controller_action_predispatch>
<observers>
<ob_extensions>
<type>singleton</type>
<class>obbase/feed_extensions</class>
<method>check</method>
</ob_extensions>
<ob_upds>
<type>singleton</type>
<class>obbase/feed_updates</class>
<method>check</method>
</ob_upds>
</observers>
</controller_action_predispatch>
</events>
</adminhtml>
</config>
<?xml version="1.0"?>
<config>
<tabs>
<obbase translate="label" module="obbase">
<label>OnlineBizSoft</label>
<sort_order>300</sort_order>
</obbase>
</tabs>
<sections>
<managekey translate="label" module="obbase">
<label>Manage License Keys</label>
<tab>obbase</tab>
<frontend_type>text</frontend_type>
<sort_order>9999</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<general translate="label">
<label>License Keys Manager </label>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<keys>
<label>License Key</label>
<frontend_type>textarea</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment><![CDATA[Enter your license keys, each per row.]]></comment>
</keys>
</fields>
</general>
</groups>
</managekey>
<obbase translate="label" module="obbase">
<label>Extensions Info</label>
<tab>obbase</tab>
<frontend_type>text</frontend_type>
<sort_order>9999</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<installed_extensions translate="label">
<label>Installed OnlineBiz Extensions</label>
<frontend_type>text</frontend_type>
<frontend_model>obbase/system_config_form_fieldset_extensions</frontend_model>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</installed_extensions>
<extensions_conflict translate="label">
<label>Extensions Conflict</label>
<frontend_type>text</frontend_type>
<frontend_model>obbase/system_config_form_fieldset_conflict</frontend_model>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</extensions_conflict>
</groups>
</obbase>
<storeview translate="label" module="obbase">
<label>Hot Plugins Today</label>
<tab>obbase</tab>
<frontend_type>text</frontend_type>
<sort_order>999</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<extensions translate="label">
<label>OnlineBiz Extensions Store</label>
<frontend_type>text</frontend_type>
<frontend_model>obbase/system_config_form_fieldset_store</frontend_model>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</extensions>
</groups>
</storeview>
</sections>
</config>
<?xml version="1.0"?>
<layout>
<default>
<reference name="head">
<action method="addCss"><name>onlinebizsoft/obbase/css/base.css</name></action>
</reference>
</default>
<adminhtml_system_config_edit>
<reference name="content">
<block type="obbase/store" name="onlinebiz_store" template="onlinebizsoft/obbase/store.phtml"></block>
</reference>
</adminhtml_system_config_edit>
</layout>
\ No newline at end of file
<?php
/**
* Extensions Manager Extension
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://store.onlinebizsoft.com/license.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to admin@onlinebizsoft.com so we can mail you a copy immediately.
*
* @category Magento Extensions
* @package ExtensionManager
* @author OnlineBiz <sales@onlinebizsoft.com>
* @copyright 2007-2011 OnlineBiz
* @license http://store.onlinebizsoft.com/license.txt
* @version 1.0.1
* @link http://store.onlinebizsoft.com
*/
?>
<div id="message-popup-window" style="display:none;"></div>
<div style="position:relative;margin-left:-390px;">
<div id="onl_notif" class="notification" style="display:none;">
<div class="head">
<h3><?php echo $this->getHeaderText();?></h3>
<button type="button" class="close" onclick="closeMessagePopupWindow()"><span ><?php echo $this->getCloseText(); ?></span></button>
</div>
<div class="content">
<?php echo $this->getNoticeMessageText(); ?>
</div>
</div>
</div>
<script>
function showNot(){
openMessagePopupWindow();
Effect.Appear('onl_notif', { duration: 1.0 });
}
Event.observe(window, 'load', showNot);
function openMessagePopupWindow(){
var height = $('html-body').getHeight();
$('message-popup-window').setStyle({'height':height+'px'});
toggleSelectsUnderBlock($('message-popup-window'), false);
Element.show('message-popup-window');
}
function closeMessagePopupWindow()
{
toggleSelectsUnderBlock($('message-popup-window'), true);
Effect.Fade('onl_notif', { duration: 0.5 });
Element.hide('message-popup-window');
}
function saveCloseMessagePopupWindow()
{
$('onl_firstrun').request({
onComplete: function(){
toggleSelectsUnderBlock($('message-popup-window'), true);
Effect.Fade('onl_notif', { duration: 0.5 });
Element.hide('message-popup-window');
}
})
}
</script>
<div id="onlinebiz_store" style="display:none">
<?php echo $this->_getStoreData()->getTextResponse()?>
</div>
<script type="text/javascript">
_section = '<?php echo $this->_section?>';
</script>
<?xml version="1.0"?>
<config>
<modules>
<OnlineBiz_ObBase>
<active>true</active>
<codePool>local</codePool>
</OnlineBiz_ObBase>
</modules>
</config>
\ No newline at end of file
function initBase(){
if(_section == 'storeview'){
$('storeview_extensions').update($('onlinebiz_store').innerHTML)
}
}
Event.observe(window, 'load', function() {
initBase();
});
/*Base style*/
#managekey_general_keys {width:340px !important}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment