forked from MageBridge/MageBridgeCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
78 lines (65 loc) · 2.24 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Joomla! component MageBridge
*
* @author Yireo (info@yireo.com)
* @package MageBridge
* @copyright Copyright 2015
* @license GNU Public License
* @link http://www.yireo.com
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
/**
* HTML View class
*
* @static
* @package MageBridge
*/
class MageBridgeView extends YireoView
{
/**
* Display method
*
* @param string $tpl
* @return null
*/
public function display($tpl = null)
{
// Add CSS-code
$this->addCss('backend.css', 'media/com_magebridge/css/');
if (MageBridgeHelper::isJoomla25()) $this->addCss('backend-j25.css', 'media/com_magebridge/css/');
if (MageBridgeHelper::isJoomla35()) $this->addCss('backend-j35.css', 'media/com_magebridge/css/');
// If we detect the API is down, report it
$bridge = MageBridgeModelBridge::getInstance();
if ($bridge->getApiState() != null) {
$message = null;
switch(strtoupper($bridge->getApiState())) {
case 'EMPTY METADATA':
$message = JText::_('COM_MAGEBRIDGE_VIEW_API_ERROR_EMPTY_METADATA');
break;
case 'SUPPORTKEY FAILED':
$message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_KEY_FAILED', $bridge->getApiExtra());
break;
case 'AUTHENTICATION FAILED':
$message = JText::_('COM_MAGEBRIDGE_VIEW_API_ERROR_AUTHENTICATION_FAILED' );
break;
case 'INTERNAL ERROR':
$message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_INTERNAL_ERROR', MageBridgeHelper::getHelpLink('troubleshooting'));
break;
case 'FAILED LOAD':
$message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_FAILED_LOAD', MageBridgeHelper::getHelpLink('faq-troubleshooting:api-widgets'));
break;
default:
$message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_GENERIC', $bridge->getApiState());
break;
}
MageBridgeModelDebug::getInstance()->feedback($message);
}
// If debugging is enabled report it
if (MagebridgeModelConfig::load('debug') == 1 && JFactory::getApplication()->input->getCmd('tmpl') != 'component' && in_array(JFactory::getApplication()->input->getCmd('view'), array('config', 'home'))) {
MageBridgeModelDebug::getInstance()->feedback('COM_MAGEBRIDGE_VIEW_API_DEBUGGING_ENABLED');
}
parent::display($tpl);
}
}